thisizmonster

Untitled

Nov 19th, 2013
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.54 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class bombAI : MonoBehaviour {
  5.  
  6.     float detonateTime = 3f;
  7.     public GameObject explosionBomb;
  8.  
  9.     void Start () {
  10.    
  11.         StartCoroutine (destroyBomb());
  12.     }
  13.  
  14.     void OnTriggerExit (Collider other) {
  15.  
  16.         if (other.tag == "player") {
  17.  
  18.             this.gameObject.AddComponent ("SphereCollider");
  19.         }
  20.     }
  21.  
  22.     IEnumerator destroyBomb() {
  23.  
  24.         yield return new WaitForSeconds(detonateTime);
  25.         Destroy (this.gameObject);
  26.         Instantiate (explosionBomb, transform.position, Quaternion.identity);
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment