using UnityEngine; public class DestroyAfterTime : MonoBehaviour { //given a time, count in delta time until the time is reached. Once reached, destroy the attached object. public float waitTime; private float timeWaited; private void Update() { timeWaited += Time.deltaTime; if (timeWaited >= waitTime) { Destroy(this.gameObject); } } }