hello there i am making a video game that require a obstacle generator similar to the one in flappy birds when the character goes though the trigger located in the center of the obstacles it is suppose to spawn another obstacle a few units up one at a time but it spawns a whole bunch in the air which slows down my computer can you guys help me make it spawn one at a time thx here is my script
#pragma strict
var max : float = 5;
var min : float = 0;
var obstacle : GameObject;
var regenerate : boolean = false;
var far : float = 0;
var yes : boolean = true;
function Start () {
}
function Update () {
var x = Random.Range ( min, max);
var y = far + transform.position.y;
if(regenerate){
Instantiate( obstacle, Vector3(x,y,0),Quaternion.identity);
regenerate = (false);
}
}
function OnTriggerEnter2D (other: Collider2D) {
{
regenerate = (true);}
}