Destroy an object after animation finish “Unity Script”

If you want to destroy a game object after finishing his animation.

For example when Instantiate a prefab of explosion effect.

Only you need to add that script to prefab and run the game in unity3D.

public float delay = 0f; //delay after animation finish (change it if you want)

using UnityEngine;
using System.Collections;

public class AnimationAutoDestroy : MonoBehaviour
    public float delay = 0f;

    // Use this for initialization
    void Start()
        Destroy(gameObject, this.GetComponent<Animator>().GetCurrentAnimatorStateInfo(0).length + delay);

If you have any problem leave a comment, and I am here to help you 🙂

For more: Click Here