Skip to content

Instantly share code, notes, and snippets.

@eduardonunesp
Last active September 1, 2022 19:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardonunesp/29f4cf474ba14ad6f186efd0fbc6239b to your computer and use it in GitHub Desktop.
Save eduardonunesp/29f4cf474ba14ad6f186efd0fbc6239b to your computer and use it in GitHub Desktop.
Destroy Game Object after animation end
using UnityEngine;
public class ExplosionCenter : MonoBehaviour
{
// Use this for initialization
void Start()
{
Destroy(gameObject, this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length);
}
}
@MrKatonic
Copy link

Thank you for this! It works like a charm, and is much simpler than other potential solutions I have seen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment