I´m trying to do a small game where balls change color each x seconds.
I set it to change each 5 seconds, for example, so first time it runs color changes to blue and random wait 5 seconds to keep running and change to next value but, next time it finds a value between 0 and 1 yield is ignored. What´s the problem in the code?
var valor : float;
var cambiar : boolean = true;
function Update () {
if(cambiar)
{
aleatorio();
};
if((valor > 0) (valor < 1))
{
Azul();
};
}
function aleatorio()
{
valor = Random.value * 7;
};
function Azul()
{
cambiar = false;
renderer.material.color = Color.blue;
yield WaitForSeconds(5);
cambiar = true;
};