Invoke Repeating Rate

Hi,

i have this code:

InvokeRepeating(“SetTime”, 0, timeSpawn);

and i have the timeSpawn variable changing, so i need this to be dynamic. What i find out is that i cant directly change rate of invoke like this as it is called only once.

Is there some way around it ? I read here about using yielding for this. But i kind of struggle with it. Is there any solution to have dynamic invoke repeating ?

thanks

Luke

Just write the code manually as a co-routine:

function SpawnStuff()
{
    while (true) {
        SetTime();
        yield WaitForSeconds(timeSpawn);
    }
}

Then just call that function to start it invoking, just as you currently do with InvokeRepeating.

No need to fear coroutines.