kizn
New vMember
Posts: 11
|
Post by kizn on Jul 4, 2020 16:55:56 GMT
Hi there,
I am trying to change the camera state when sprinting. The same thing that is done with "Crouch" state. I couldn't find it anywhere in the code. Could you please advise on how to obtain this result? Does it have to be a separate component for this specific key input? Or how can it be done? (I am currently using Third Person Controller - Melee Combat Template
Thank you
|
|
|
Post by hobbycoder on Jul 6, 2020 22:11:06 GMT
Under events inside thirdpersoncontroller, you can add ur camera state on start sprinting
|
|
kizn
New vMember
Posts: 11
|
Post by kizn on Jul 7, 2020 11:36:03 GMT
Under events inside thirdpersoncontroller, you can add ur camera state on start sprinting Thank you for your reply. I figured it out that this option only work when useContinuousSprint is marked as true. Even though with useContinuousSprint unchecked I still see the Is Sprinting = true; in the debuger. And the On Finish Sprinting is not reseting my camera state to Default. I even triend ChangeCameraStateWithLerp to Default and still get stuck in the On Start Sprinting() state. Any help is appreciated. Thank you
|
|
|
Post by Invector on Jul 7, 2020 13:07:42 GMT
Under events inside thirdpersoncontroller, you can add ur camera state on start sprinting Thank you for your reply. I figured it out that this option only work when useContinuousSprint is marked as true. Even though with useContinuousSprint unchecked I still see the Is Sprinting = true; in the debuger. And the On Finish Sprinting is not reseting my camera state to Default. I even triend ChangeCameraStateWithLerp to Default and still get stuck in the On Start Sprinting() state. Any help is appreciated. Thank you Open your vThirdPersonController script and replace the Sprint method to this, the events were not being called correctly public virtual void Sprint(bool value) { var sprintConditions = (currentStamina > 0 && hasMovementInput && isGrounded && !customAction && !(isStrafing && !strafeSpeed.walkByDefault && (horizontalSpeed >= 0.5 || horizontalSpeed <= -0.5 || verticalSpeed <= 0.1f) && !sprintOnlyFree));
if (value && sprintConditions) { if (currentStamina > (finishStaminaOnSprint ? sprintStamina : 0) && hasMovementInput) { finishStaminaOnSprint = false; if (isGrounded && useContinuousSprint) { isCrouching = false; isSprinting = !isSprinting; if (isSprinting) OnStartSprinting.Invoke(); else OnFinishSprinting.Invoke(); } else if (!isSprinting) { OnStartSprinting.Invoke(); isSprinting = true; } } else if (!useContinuousSprint && isSprinting) { if (currentStamina <= 0) { finishStaminaOnSprint = true; OnFinishSprintingByStamina.Invoke(); } isSprinting = false; OnFinishSprinting.Invoke(); } } else if (isSprinting && (!useContinuousSprint || !sprintConditions)) { if (currentStamina <= 0) { finishStaminaOnSprint = true; OnFinishSprintingByStamina.Invoke(); }
isSprinting = false; OnFinishSprinting.Invoke(); } }
|
|
kizn
New vMember
Posts: 11
|
Post by kizn on Jul 8, 2020 19:51:41 GMT
That is exactly what I was looking for. Thank you sir! Just a little mention: With !useContinuousSprint and jumping while sprinting there is a fast state switch to Default from Sprinting right at landing. Is that only in my project? Can I fix it? I already took out isGrounded and conditioned the sprint for isCrouching. (not sure how to add code syntax in post, sorry!) var sprintConditions = (currentStamina > 0 && hasMovementInput && !customAction && !isCrouching && !(isStrafing && !strafeSpeed.walkByDefault && (horizontalSpeed >= 0.5 || horizontalSpeed <= -0.5 || verticalSpeed <= 0.1f) && !sprintOnlyFree));
|
|
|
Post by Invector on Jul 9, 2020 14:26:05 GMT
The landing animation use the tag "CustomAction" which is included in the sprintContidions, so you can either remove the tag from the animation clip or the conditions from the sprintCondition
|
|
kizn
New vMember
Posts: 11
|
Post by kizn on Jul 9, 2020 17:37:18 GMT
The landing animation use the tab "CustomAction" which is included in the sprintContidions, so you can either remove the tag from the animation clip or the conditions from the sprintCondition Thank you for this awesome asset and thank you for your time! Congrats for the Posts: 3,500 milestone!
|
|