0
\$\begingroup\$

I want the animation state normalized time not to go beyond 1 when it is not looped. I initially thought that it shouldn't do it anyway but the longer the animator stays in that state, normalized time will non-stop go forever.

I have created a StateMachineBehaviour and added the following code for the said state:

public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
            var normalizedTime = stateInfo.normalizedTime;
            
            if (normalizedTime > 1)
                animator.Play(0, layerIndex, 1);
}

This simply checks if the normalizedTime has gone beyond 1 and if so, it resets it back to 1. This sadly comes back with tons of errors in the console though: "Invalid time range for Transition exit time condition" when there is a transition with has exit time checked and no transition will work.

Please help me fix this. Thanks.

\$\endgroup\$
1
  • \$\begingroup\$ What are you using normalized time for, that misbehaves when the number is above 1? It may be easier to fix the problem there. \$\endgroup\$
    – DMGregory
    Jan 9 at 14:50

You must log in to answer this question.

Browse other questions tagged .