Get when the animation is finished
Hello. I need to get when the animation is finished, so I tried to use the property normalizedTime, but this property says that the animation is finished when it turns to 1, but it actually never turns to 1, just to some number like 0.9943789564 and I cant get a precision to increment a counter. Look:
if (mao.GetCurrentAnimatorStateInfo(0).normalizedTime == 1)
{
contMovimento++;
Debug.Log(contMovimento);
}
If i try to use something like >= 0.999 it will enter in this condition more than one time, so I'll lost the precision of the counter. Can someone help me how to increment a counter with precision when the animation is finished?
Answer by Hsni · Jun 28, 2018 at 12:20 PM
You need one more condition along with this one anim.GetCurrentAnimatorStateInfo (0).normalizedTime >= 0.99f && !anim.IsInTransition (0)
Your answer
![](https://koobas.hobune.stream/wayback/20220612165625im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Animations get screwed up when I add OnAnimatorMove function 0 Answers
Falling blocks skip animation while upside down 1 Answer
How too climb a ladder with the FPS Controller correctly 0 Answers
What type of variable would I declare an animatable object as? (C#) 2 Answers
OVR Walking Animation trigger. 0 Answers