I am following along with the tutorial for the climbing feature but my Pull Up state is transitioning to free look as soon as I hit the key despite using an if statement checking normalized time <1. If I comment out the line to switch states to free look then it completes the animation. Any ideas?
public class PlayerPullUpState : PlayerBaseState
{
private readonly int PullUpHash = Animator.StringToHash("BasicLedgePullUp");
private const float CrossFadeDuration = 0.1f;
//Offset to move character controller to new position after pull up animation
private readonly Vector3 Offset = new(0f, 2f, 1f);
public PlayerPullUpState(PlayerStateMachine stateMachine) : base(stateMachine)
{
}
public override void Entry()
{
stateMachine.Animator.CrossFadeInFixedTime(PullUpHash, CrossFadeDuration);
}
public override void Tick(float deltaTime)
{
if (stateMachine.Animator.GetCurrentAnimatorStateInfo(0).normalizedTime < 1f) { return; }
Debug.Log("Transition to FreeLook");
//In order to handle the root motion of the pullup animations, turn off controller to allow translate(), then renable
stateMachine.Controller.enabled = false;
stateMachine.transform.Translate(Offset, Space.Self);
stateMachine.Controller.enabled = true;
stateMachine.SwitchState(new PlayerFreeLookState(stateMachine));
}
public override void Exit()
{
stateMachine.Controller.Move(Vector3.zero);
stateMachine.ForceReceiver.Reset();
}
}
Here is a screen shot of my animation