using UnityEngine; using System.Collections; public class DelayDestroy : MonoBehaviour { public float delay = 5f; protected float startTime; // Use this for initialization protected void Start () { startTime = GameTime.time; } protected void OnEnable() { startTime = GameTime.time; } // Update is called once per frame protected virtual void FixedUpdate () { if(GameTime.time - startTime > delay) { Destroy(this.gameObject); } } }