How to check if Animator has finished playing an animation ?

I want to check if Animator has finished playing animation then the game object should move else it should wait for the animation to finish then move.

bool AnimationHasFinished()
    {
        return (myAnimator.GetCurrentAnimatorStateInfo(0).normalizedTime > 1.0f);
    }

if(AnimationHasFinished())
{
    // GameObject Move
}

How to wait for the animation to finish then move

what does not work with this current code of yours?

1 Answer

1

Just check if the current animation is the one you want.
If not, then it’s another one so it’s not playing your animation anymore.

animator.GetCurrentAnimatorStateInfo(layer).IsName("AnimName")