check if animator animation is done playing?

hi i know how to check if animation has stopped playing without animator but with animator is it different? how do i do it?

I did it in a different way. I added a StateMachineBehaviour script to the animation that changes a bool variable in the animator to true when the animation exit:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CheckAnimationStatus : StateMachineBehaviour {
     // OnStateExit is called when a transition ends and the state machine finishes evaluating this state
     override public void OnStateExit(Animator animator, AnimatorStateInfo stateInfo, int layerIndex) {
        animator.SetBool("EnemyExploded", true);

Then, in the game object I want to be notified, I added a simple line that check if that bool was set to true:

if (animator.GetBool ("EnemyExploded")) {
    // Do something

You should use exit time. In the animator is a default variable when setting up transitions.
in the transition just leave it as exit time = 0.9 (90% finished) and add any other if statements onto that. Then it wont transition until the animation is done.

Here is a short example of finding references between a single StateMachineBehaviour and a MonoBehaviour.
In your MonoBehaviour class:

public class ExampleMonoBehaviour : MonoBehaviour
    public bool didExitState {
        set {
            didExitState = value;
            // trigger something on setter

    private Animator animator;                          // Reference to the Animator component on this gameobject.
    private ExampleStateMachineBehaviour exampleSmb;    // Reference to a single StateMachineBehaviour.

    void Awake ()
        // Find a reference to the Animator component in Awake since it exists in the scene.
        animator = GetComponent  ();

    void Start ()
        // Find a reference to the ExampleStateMachineBehaviour in Start since it might not exist yet in Awake.
        exampleSmb = animator.GetBehaviour  ();

        // Set the StateMachineBehaviour's reference to an ExampleMonoBehaviour to this.
        exampleSmb.exampleMb = this;

In your StateMachineBehaviour:

public class ExampleStateMachineBehaviour : StateMachineBehaviour
    public ExampleMonoBehaviour exampleMb;

        public override void OnStateExit(Animator animator, AnimatorStateInfo animatorStateInfo, int layerIndex) {
            exampleMb.didExitState = true;

See: Survival Shooter Training Day Phases - Unity Learn

If you do not have any transitions and would like to to be notified when the animation has ended for the “stateName” in layer 0, I did by calling the following IEnumerator :

public IEnumerator PlayAndWaitForAnim(Animator targetAnim, string stateName)

     //Wait until we enter the current state
     while (!targetAnim.GetCurrentAnimatorStateInfo(0).IsName(stateName))
         yield return null;

     //Now, Wait until the current state is done playing
     while ((targetAnim.GetCurrentAnimatorStateInfo(0).normalizedTime) % 1 < 0.99f)
         yield return null;

     //Done playing. Do something below!

The main logic is once the state is entered, we should check if the fractional part of ‘normalizedTime’ variable reached 1, which means the animation has reached its end state.

Hope this helps

Ah was typing my comment when your update came in. Probably easiest to set the time as I said and set a bool, the reach down/up are generally one animation so just test what works for your animation but something like this.

private bool loadingGun = false;
private float atGunTime = 0.54f;
private float atGun;

// when the button/key that tells it start the animation is pressed
anim.SetBool("loadGun", true);
atGun = Time.time + atGunTime;
loadingGun = true;

// in Update
if(loadingGun && Time.time > atGun)
    //Instantiate my gun
    loadingGun = false;

You will have to play with the atGunTime to see what fits your animation but it should work.