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.

You can use animator.GetCurrentAnimatorStateInfo(layer).length:

/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().