- Home /
yield while animation plays in mecanim
Hi,
I'm slowly converting to mecanim and was wondering how I would yield while an animation plays out, I used to do -
yield WaitForSeconds(animation["PickUp"].length);
Can someone point me in the right direction please.
Answer by TonyLi · May 24, 2013 at 12:55 PM
You can use animator.GetCurrentAnimatorStateInfo(layer).length:
http://docs.unity3d.com/Documentation/ScriptReference /Animator.GetCurrentAnimatorStateInfo.html
But if you're doing something more complicated, like using a blend tree, you may want to check for a state change instead, using GetNextAnimationStateInfo().
Thanks,
anim.GetCurrentAnimatorStateInfo(2).length
done it
dam how many layers you got does it start at (0) like everyfing else lol and cas someone tell my why they do that
Your answer
![](https://koobas.hobune.stream/wayback/20220613102832im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
WaitUntil Combined With sqrMagnitude is not working? 1 Answer
Wierd issue with Coroutines? 2 Answers
yield new wait for seconds: what does "new" do? 1 Answer
help with yield function 2 Answers
C# Coroutine help 1 Answer