I have been following a quill18creates tutorial on YouTube which was about creating a simple first person shooter. I went to part 6 and got stuck. I have been doing whatever he was but for some reason a particular script just doesn’t work. It doesn’t even give me any errors. here is the script which was suppose to destroy the object after 3 secs. but nothing seems to happen. It worked for a while but when I added a point light to the object that would be destroyed by the script it stopped working. It didn’t even instantiate properly. I got rid of the point light now its instantiating but not destroying itself. Whats wrong? is there anything in the software that I should be aware of?
using UnityEngine;
using System.Collections;
public class ThermalDetonator : MonoBehaviour {
public float lifetime = 3f;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
lifetime -= Time.deltaTime;
if (lifetime == 0) {
Explode ();
}
}
void Explode() {
Destroy (gameObject);
}
}