title: How to wait for an animation to finished in Unity C#
body: <p>I want to wait for an animation clip to finish after I set the trigger. </p>
  
  <pre><code>private void Start()
  {
      anim = GetComponent&lt;Animator&gt;();
  }
  
  
  private IEnumerator Die()
  {
      // Play the animation for getting suck in
      anim.SetTrigger("Shrink")      
  
      // Wait for the current animation to finish
      while (!anim.IsInTransition(0))
      {
          yield return null;
      } 
  
      // Move this object somewhere off the screen
  
  }
  </code></pre>
  
  <p>The animation plays, but it doesn't wait to finish before it moves on to the code after the while loop. </p>
  
  <p>Here is my animator component:
  <a href="https://i.stack.imgur.com/g05rA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/g05rA.png" alt="enter image description here"></a></p>