Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class DestroyObjectOverTime : MonoBehaviour
- {
- public float lifeTime; // How long the object should live
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- lifeTime -= Time.deltaTime;// Subtract Time.deltaTime from lifeTime
- if(lifeTime <= 0)// If lifeTime is less than or equal to 0
- {
- Destroy(gameObject);// Destroy the game object
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement