Following on froma recent question I’m trying to limit how many instantiated objcts can spawn. Simply I wnat one object to respawn, at the set location but it’s instantiating thousands causing a lot of problems for my computer ha!
Where could I be going wrong? Seems okay to me, but I know little SO i ask you guys for help…
var wave2 : boolean;
function Start(){
var someScript : playerScript;
someScript = gameObject.GetComponent("playerScript");
wave2 = false;
}
function Update(){
amtToMove = enemySpeed * Time.deltaTime;
transform.Translate(Vector3.down * amtToMove);
if(block.position.y<=20){
playerScript.playerScore +=5;
transform.position.y = 31;
transform.position.x = Random.Range(-7,7);
}
if(playerScript.playerScore == 0 && wave2 == false){
var tempBlock : Transform;
tempBlock = Instantiate(blocked, Vector3(0,32,0), Quaternion.identity);
wave2 = true;
}