Destroy Object after time

To destroy an object after an amount of time simply create a new cSharp script called “Destroyitem” and then in monodevelop paste in the following code:

using UnityEngine;
using System.Collections;

public class DestroyItem : MonoBehaviour {

    public float Life;
    void Start(){

        Invoke(DestroyIt,Life);
    }

    void DestroyIt(){
        Destroy(gameObject);}

    void Update () {

    }
}

Then drag this script onto the object you want to disappear, The word “Life” will give you a box that you can input a time. This gives you the ability to have different objects last for different amounts of time. Enjoy!