Call a function at the end of an animation

Hi, my problem is twofold: First, what’s the best GUARANTEED way to call a function when an animation is finished? I tried using an animation event on or near the last frame of the animation, but that proved very unreliable. Now I’m trying this

if (player1Animator.GetCurrentAnimatorStateInfo(0).IsName (“Pl1ParryMenStrike”) && player1Animator.GetCurrentAnimatorStateInfo(0).normalizedTime > .99f)

which seemed to do the trick. But then I changed the name of the animation and it no longer works. I tried changing the normalized time value to less than .99 but it still didn’t work. I’ve checked the spelling of the animation’s name more time than I care to admit. Has anyone else seen a name change screw up the works?

Thanks in advance for your help.

Maybe the problem is that you’re trying to call a function when an animation ends but what you really want is to call a function when an animator state ends. Take a look at “State Machine Behaviours” and their “OnStateExit” method: Survival Shooter Training Day Phases - Unity Learn