Hey guys,
I would like to use Time.timeSinceLevelLoad as the time used in yield WaitForSeconds. How would I be able to do this?
EDIT: What I am trying to do is when Time.timeScale = 0; yield WaitForSeconds still works as it is supposed to use timeSinceLevelLoad so that it can still yield while not using Time.time as it would be using Time.timeScale which is 0.
Simply :
JS
yield WaitForSeconds( Time.timeSinceLevelLoad );
C#
yield return new WaitForSeconds( Time.timeSinceLevelLoad );
However, beware, that might be a long time if the player starts the game, go grab a coffee or whatever.
If I understood correctly what you want, just pass Time.timeSinceLevelLoad to WaitForSeconds:
yield WaitForSeconds(Time.timeSinceLevelLoad);
But this seems weird: you will get a delay that expires at twice the level duration at the moment this instruction is executed - is this what you want?
Take a look at my tutorial on Unity Gems on coroutines - the video for that includes building a version of WaitForSeconds that uses realTimeSinceStartup and hence works when the timeScale is 0. http://unitygems.com
The video is quite long :S You’d be looking to work somewhere around the 15 minute mark I seem to remember.