I am trying to destroy the clone instance as in the code below:
var projectile : Rigidbody;
var creationtime:float;
var timerfl:boolean=false;
function Update () {
var curtime:float;
if (Input.GetButtonDown("Fire1")) {
var clone : Rigidbody;
clone = Instantiate(projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.forward * .5);
creationtime=Time.realtimeSinceStartup;
timerfl=true;
}
curtime=Time.realtimeSinceStartup;
if(timerfl==true){
if((curtime-creationtime)>5)
{
timerfl=false;
Destroy(clone);
}
}
}
but the clone is not destroyed, what am I doing wrong? Thanks