Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class bombAI : MonoBehaviour {
- float detonateTime = 3f;
- public GameObject explosionBomb;
- void Start () {
- StartCoroutine (destroyBomb());
- }
- void OnTriggerExit (Collider other) {
- if (other.tag == "player") {
- this.gameObject.AddComponent ("SphereCollider");
- }
- }
- IEnumerator destroyBomb() {
- yield return new WaitForSeconds(detonateTime);
- Destroy (this.gameObject);
- Instantiate (explosionBomb, transform.position, Quaternion.identity);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment