Character disappears when dies.

My character just disappears when he dies, i was wondering how to play the “die animation” when he dies instead of just disappearing?

Any help would be fab thanks! :slight_smile:

The code i have is:

function OnTriggerEnter (other : Collider) {


  Destroy(other.gameObject);
  animation.Play("die");
  
}

It’s disappearing because you’re destroying it. Remove the Destroy call.

If you want your object disappear after the animation, modify your code to:

function OnTriggerEnter (other : Collider) {

  animation.Play("die");

}

private void Kill() {
  //Destroy your player or whatever you
  //want to happen at the end of your animation
}

You can then attach Kill() in the end of the [die] animation via animation event

And the Kill() function will be called in the end of the animation (or at the frame you have assigned the function to)

I think you should use Destroy(other.Gameobject,10); this code will destroy your gameobject after 10 sec so in that 10 sec you play the animation.Play(“Die”); for better visualization you can use your animation time’s lenght +1 or +2 sec…means if the animation is of 10 sec then destroy at 12…by using Destroy(other.Gameobject,12);…Here 12 represent time in sec to wait before destroy the object
Hope This will work for you…Enjoy