Search Unity

  1. All Pro and Enterprise subscribers: find helpful & inspiring creative, tech, and business know-how in the new Unity Success Hub. Sign in to stay up to date.
    Dismiss Notice
  2. Dismiss Notice

Help Wanted 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:
    190
    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:
    1,615
    If the first one works, the second one will too so you must be doing something else wrong.
     
unityunity