I have been working on a side scroller type game and have alot of my code run in the fixed update method, I currently pause the game using Time.timescale = 0; which works perfectly, however I am adding the in game menu at the moment and would like the buttons to ‘slide’ onto the screen instead of just appear, I have written the following coroutine to make this happen
function Slide() {
for (var i: int = -10; i < 0; i++) {
ofset = 10 * i;
yield WaitForSeconds(0.1f);
}
ofset = 0;
}
Now this works perfectly however it doesn’t run at all while Time.timescale = 0, which I do on pause of course, is there any work around to this, so that I can force my that coroutine to run regardless of timescale?
yield return null; should always wait for the next frame, regardless of timescale. But that messes up the time – it used to finish in 10*0.1=1 second. Now it runs in 10 frames (1/6th to 1/3rd of a second?) So just rewrite the loop to take 30 small 1-frame steps.