I made a script, and when the timer reaches 0 I want it to only spawn 1 enemy but it keeps spawning.
What do I add to the script pls help.
var timer : float = 10.0;
var enemy : Rigidbody;
var sound : AudioClip;
function Update () {
timer -= Time.deltaTime;
if(timer <= 0)
{
var clone : Rigidbody;
clone = Instantiate(enemy, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.forward);
AudioSource.PlayClipAtPoint(sound, transform.position, 1);
}
}
↧