Search Unity

Question How can I check if Animator ended playing specific State animation?

Discussion in 'Animation' started by shamenraze1988, Jun 6, 2021.

  1. shamenraze1988

    shamenraze1988

    Joined:
    Nov 24, 2020
    Posts:
    208
    This way it's getting inside all the time while the animation state is playing :

    Code (csharp):
    1.  
    2.     void Update()
    3.         {
    4.             if (this.animator.GetCurrentAnimatorStateInfo(0).IsName("Stand Up"))
    5.             {
    6.                 string tt = "";
    7.             }
    8.         }
    9.  
    So I tried to add ! to check if it false :

    Code (csharp):
    1.  
    2.     void Update()
    3.         {
    4.             if (!this.animator.GetCurrentAnimatorStateInfo(0).IsName("Stand Up"))
    5.             {
    6.                 string tt = "";
    7.             }
    8.         }
    9.  
    but this way it's never getting inside even if the state animation finished playing.

    I have one Base Layer in the animator controller.
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    If the first one works, the second one will too so you must be doing something else wrong.