Play Animation After Destroy Gameobject

Can i play animation after destroy my gameobject?

So i set transition for my animation into bool. While gameobject destroy that bool set true.

But my animation cant play.

please describe the question more. as i understand you are going to play an animation assigned object, and the object is destroying. so you can’t play a animation after selected game object is destroyed. because game object didn’t exists.

  1. Try to delay the destroy( once you want a destroy the object first animate and then destroy.)
  2. Try to control animator using separate game object Animation Manager.

Not sure if you still use this.
But I think you should do it the other way around.
Play the animation and then destroy the Object.
If you destroy the object there won’t be any Object to play the animation on, right?

For me this did the trick:

//Create the method that plays the animation, waits, and destroys the object.

  IEnumerator  DestroyTimer()
        yield return new WaitForSeconds(1.2f);

Add the function on your collision or where you want the animation to be played and destroyed.


That should do the trick

Destroy (gameObject, animator.GetCurrentAnimatorStateInfo(0).length);

This solution is simpler thanks

I don’t know if this sounds like an overkill, but you can have a prefab dedicated to play the animation. And the original object just instantiate the prefab and instantly destroy itself.