using System.Collections; using System.Collections.Generic; using UnityEngine; public class DestroyTimer : MonoBehaviour { // Start is called before the first frame update void Start() { startTime = Time.time; } // Update is called once per frame void Update() { if (Time.time - startTime > duration) { Destroy(this.gameObject); } } private float startTime; [Tooltip("The length of time before this gameobject is destroyed")] public float duration = 3.0f; }