Jump event not working properly

Do you think that if I base the state change from jumping to falling based on some length of time it would work?

Actually, I am completely wrong. When we are in the jump state we check if the y-velocity is below 0 to determine if we should transition to the fall state. But with the slope being as steep as it is, we ‘hit’ the slope before we start moving down, so the y-velocity never drops below 0 until we reach a less steep area. We are, in fact, staying in the jump state. Time (or animation duration) may be an option.

Change this (in PlayerJumpingState)

//if(stateMachine.CharacterController.velocity.y <= 0)
if (stateMachine.Animator.GetCurrentAnimatorStateInfo(0).normalizedTime >= 1f)
{
    stateMachine.SwitchState(new PlayerFallingState(stateMachine));
    return;
}

and give that a go. This will complete the jump animation and transition to the fall state.

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.

Privacy & Terms