Wait For animation to finish

Hey Guys,

I’m trying to wait for animation to be completed before doing the next action. I’ve tried a few things that haven’t worked.

private IEnumerator WaitForComplete()
        {
            Debug.Log("Not Done");
            while (_anim.GetCurrentAnimatorStateInfo(0).IsName("SwordStart") && _anim.GetCurrentAnimatorStateInfo(0).normalizedTime < 1.0f)
            {
                yield return null;
            } 
            Debug.Log("Done");
        }

Try using animation events. Put an animation event at the end of the animation that calls a function on the script. In there you can do whatever you want to do after the animation is finished.

I made a small package which you can use to wait for animations to start or finish inside coroutines. You can check it out here: GitHub - ComradeVanti/UnityWaitForAnim: A custom yield-instruction for Unity to wait for animations to finish