0
\$\begingroup\$

This question already has an answer here:

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.

Please help me to find a way to make a condition "when the 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!

\$\endgroup\$

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

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0
\$\begingroup\$

What you are looking for is State Machine Behaviours

State machine behaviours are scripts that can be attached to animator states or sub-state machines in an Animator Controller. [...] To add a state machine behaviour to a state or sub-state machine, click the Add Behaviour button in the inspector.

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)
{
    animator.SetBool("someparameter",false);
}
\$\endgroup\$

Not the answer you're looking for? Browse other questions tagged or ask your own question.