# How to detect when the current animation is finished in code in Unity's Animator? [duplicate]

I have a model with an animation controller. I set the states and parameters for transitions between them. Now I need to make the model play its animations in the order I want.

I can use:

GetComponent.<Animator>().SetBool("someparameter",true);


to uncheck currently checked parameter and check another parameter after current animation finished.

The examples I'm finding are related to animation component (not animator), or they are too complicated for me, while I need a simple way I can understand and use quickly.

Thank you so much in advance!

## marked as duplicate by DMGregory♦, Alexandre Vaillancourt♦, Gnemlock, Engineer, Josh♦May 4 '17 at 15:58

Then, on the newly created state machine behaviour file, implement the OnStateExit callback and set the value of your parameter
override public void OnStateExit (Animator animator, AnimatorStateInfo stateInfo, int layerIndex)