I’m kinda new to scripting and i tried to make a respawning script for my game.
But i just can’t get it to work, I only got it to creating thousands and thousand of guys, so many it took ages before i could quit.
What am i doing wrong? here it is:
var Enemy : Transform;
function Update ()
{
if(GameObject.Find(“Robot2”) == false)
{
Invoke(“respawnEnemy”, 5);
}else
{
CancelInvoke();
}
}
function respawnEnemy()
{
var position : Vector3;
for(var i : int = 0; i < 5; i++)
{
position = Vector3(Random.Range(-10, 10), 0, Random.Range(-10, 10));
Instantiate(Enemy, position, Quaternion.identity);
}
}