normalized time always greater than 1 on non-looped animations.

I’m trying to use the AnimatorStateInfo.normalizedTime property to allow me to execute code when the time reaches a specific percentage of the animation time.

I’d much rather use specfic keyframes but there doesn’t seem to be a way to get what frame the animation is currently on…

The issue is that I have a non-looped animation, that is only playing once, and as soon as the animation starts, the normalized time is already over 1. According to documentation, it should only ever be between zero and never exceed 1 for non-looped animations.

So far everything is (more or less) working as expected, but the SendBallInMotion() function is called as soon as the animation starts, rather than at the end of the animation (because the normalizedtime is way over what it should be).

Is there a better way to do this sort of thing?

thanks
David

Below is a screen grab of the breakpoint at the entry to a switch. You can see, that the first time this code executes, the normalizedTime is already at 1.73 and the animation hasn’t even started yet.

59880-normalizedtime.jpg

You can use similar code like this o fix the problem

 AnimatorStateInfo info =  m_Animator.GetCurrentAnimatorStateInfo(0);
 if (info.normalizedTime > 1 && info.shortNameHash == YOUR_ CURRENT_ANIM_HASH_NAME)
{
    //do something...............
}

The normalizedTime is updated late so it still keep the old value from the previous animation. So it require some frame to update new state.