Detecting the loop point of an animation

I have an animation set to “wrapMode=WrapMode.Loop”, what I want to do is update a variable at the end of the animation loop. I have tried checking the variables “animation.time” and “animation.normalizedTime”. The problem is that both of those variables keep counting up continuously as long as the animation is playing.

normalizedTime is supposed to give a value between 0 and 1, but it doesn’t. It gives the same incrementing variable as “animation.time” does.

Any idea if I am not using normalizedTime correctly or is there another way to detect the loop point of a looping animation?

Thanks.

hi,
u can use the reste ! means :

we suppose a varriable “T” that will increase forever from 0 to infinite,
if i want to check for example when “T” is looping at a specified value “L” i would do :
if (T % L == 0) // actually it calculates the reste of the perfect division of T / L

But T and L must be integers, if not , u can use Mathf.floor to switch from float into an integer value .

examples :
12 % 3 = 0
13 % 3 = 1
14 % 3 = 2
15 % 3 = 0
16 % 3 = 1
…etc

Keep going.

Thanks. I was thinking of doing something like that. I just thought something so useful would be included in the unity scripting language. I’m also surprised that normalizedTime doesn’t work the way says in the documentation

A more general solution is to use AnimationEvents to call a function at any point in your animation, though that does have its own quirks as well.