Hi,
I’ve been working on a shooting mechanic and the firing and everything is working fine. However, i don’t know how to make it so that the bullets destroy after a certain amount of time. I’ve tried various methods but none seem to work. I want it so that I can still fire bullets after it has already destroyed some of the already fired ones. Any idea on how I might do that?
#pragma strict
var bullet : Rigidbody;
var bulletSpeed : int = 1;
function Start () {
}
function Update () {
if (Input.GetMouseButtonDown(0))
{
//Debug.Log ("Left click detected");
bullet = Instantiate (bullet, this.transform.position, Quaternion.identity);
bullet.AddRelativeForce(Camera.main.transform.forward * bulletSpeed);
}
}