animation to animator [mecanim]

Hi, i’m just no longer motivated for create games in unity, the new animation system is too complex, i know that i’ve already ask that here but i can’t find a answer.

how can i simply convert that old code:

if(Input.GetKeyDown(KeyCode.R)) {
   animation.clip = reloadAnim;
   animation.Play();
}

to mecanim? (Just to play ONCE)

i’ve tryed things like ativating and desativating the mecanim bool in a coroutine but it doesn’t work.

Someone can translate that code and give me the instructions on animator?

Create a new Animator state which uses your reload animation clip as its motion field.

Then, create a transition to this new state based on a trigger parameter called “Reload”, and set the transition out of the reload state based on the animation exit time.

Then to transition to the reload state you just set the trigger from code:

Animator animator = GetComponent<Animator>();

if(Input.GetKeyDown(KeyCode.R)) {
    animator.SetTrigger("Reload");
}