Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- /// <summary>
- /// Explosion destroy.
- /// This script sets a timed destroy counter.
- /// </summary>
- public class ExplosionDestroy : MonoBehaviour {
- //Variables Start
- private Transform myTransform; //Quick Reference
- private float expireTime = 5; //The lifetime of the explosion (GameObject)
- // Use this for initialization
- void Start () {
- //As soon as the explosion is created start a countdown to destroy it
- StartCoroutine (DestroyMyselfAfterSomeTime ());
- }
- // Update is called once per frame
- void Update () {
- }
- IEnumerator DestroyMyselfAfterSomeTime()
- {
- //Wait for the timer to count up to the expireTime and then destory the projectile
- yield return new WaitForSeconds (expireTime);
- Destroy (myTransform.gameObject);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement