Is it possible to change Invoke Repeating rate on the fly?

Hi,

I have this code, it's pretty self-explanatory:

InvokeRepeating( "InstantiatePlatform", 1 , 6/globalSpeed );

function InstantiatePlatform () {

Instantiate (prefab, Vector3(spawnPoint.position.x, 0, 0), Quaternion.identity);

globalSpeed +=1;

}

Unfortunately, the rate of repeating the function doesn't change. It only takes the first value and continues to instantiate objects at that rate.

When I think about it, it's logical since InvokeRepeating doesn't update, but is there a way to change speed or should I use another method?

Thanx

Check the answer I posted here:

http://answers.unity3d.com/questions/15941/random-range-spawntime/15943#15943

Since in your case the variable globalSpeed is being set by InstantiatePlatform every time it runs, don’t use InvokeRepeating. Just use Invoke. Then have the function Invoke itself again at the end in (globalSpeed seconds).

If something somewhere else were changing the value of globalSpeed, you could check in InstantiatePlatform if globalSpeed has changed since the last time it ran, and if so, CancelInvoke(“InstantiatePlatform”) and InvokeRepeating again with the new speed.

Do not use Invoke alone ( it will instantiate your function every single time , wich meakes the whole process go slow , I started with a 78FPS ended with 4FPS only after 20000 times getting invoked .
I also tested InvokeRepeating wich does not dumps all the data after and recycles it , so therefor you can do an invoke repeating with 0.01 delay , and use another variable to track the delay manually … unfortunately not everything comes out of the box , most of it we need to make it.Good day!!