title: Unity c# Delay in order for animation to play
body: <p>I am building a c# unity game and I have encountered some troubles getting my animations to work. I am using LeanTween in order to optain those animations.</p>
  
  <p>Here's some of my code:</p>
  
  <pre><code>void Alpha()
  {
      Destroy(Cubes[aux]);
      AddCube(aux2,Map[aux]);
      ChangeColor(aux2);
      Map[aux]=0;
      Semafor = true;
  }
  
  void MoveCube(int Initial,int Final)
  {
      Semafor = false;
      EmptySpaces.Remove(Final);
      EmptySpaces.Add (Initial);
      LeanTween.move(Cubes[Initial],new Vector3(PosX[Final],PosY[Final],5),0.5f);
      aux = Initial; // auxiliar variables used because I don't know how to send params through Invoke
      aux2 = Final;
  //  Invoke( "Alpha",0.6f);
      Alpha();
  }
  </code></pre>
  
  <p>If I run the above code like this, without using Invoke it works perfectly. Problem is it destories the GameObject before the animation finishes. Therefore I need some kind of delay between the animation call and the actual call of Destroy. Problem is, the moment I try to use Invoke all functions inside Alpha start acting wierd and buggy. For example, many objects aren't actually destroied.</p>
  
  <p>I am looking for a way to make that function call after a delay. I have tried the <code>yield return new WaitforSeconds</code> method but it didn't work. Also have tried the <code>LeanTween.delaiedCall</code> thinggy but it gives me an error when I try passing Alpha because it wants a System.Action.</p>
  
  <p>I am looking for a way to make this animation work and then destroy the object without involving any collision.</p>