Calling function every x seconds but objects disappearing instantly

function is being called properly however the objects only flash into view then disappear. There is no external source causing - it works well if a keystroke calls the function within update, but on any sort of time interval, whether Invoke() or otherwise - the objects only flash for an instant

var timeBetweenTris:float = 0;

function Start () {
}

function Update () {

	timeBetweenTris += Time.deltaTime;
	if(timeBetweenTris >= 5) {
		GenerateTri();
		timeBetweenTris = 0;
	}
}

function GenerateShape() {
	var randomNumber = Random.Range(1,9);
	if(randomNumber < 4) {
		return sphere;
	}
	else if(randomNumber < 7) {
		return capsule;
	}
	else {
		return cube;
	}
}	

function GenerateTri() {
	Instantiate(GenerateShape(), positionTop, Quaternion.identity);
	Instantiate(GenerateShape(), positionLeft, Quaternion.identity);
	Instantiate(GenerateShape(), positionRight, Quaternion.identity);
}
  1. as i see you are trying to wait for some time before calling GenerateTri(); but it will work for the first time because Time.deltaTime start from 0.02 & will keep increasing so when Time.deltaTimegeting more than 5 then timeBetweenTris += Time.deltaTime;wil bee 6+0 or 7+0 so timeBetweenTris will bee always >5 .

  2. else if(randomNumber >3 && < 7)

  3. lastly if i understand you want to instantiate a 3 random objects after a delay of time you can use much easier way :

     public GameObject[] objs;//attach objects to this array in inspector.
     void Start () 
    	{
    		StartCoroutine (GenerateTri());
    	}
    IEnumerator GenerateTri()
    {
    Instantiate(objs[Random.Range (0, objs.GetLength (0))], positionTop, Quaternion.identity);
    Instantiate(objs[Random.Range (0, objs.GetLength (0))], positionLeft, Quaternion.identity);
    Instantiate(objs[Random.Range (0, objs.GetLength (0))], positionRight, Quaternion.identity);
    yield return new WaitForSeconds (5f);
    }