sjj100
1
I am coding a script where I want the script to wait for 10 seconds before changing the time scale back to 1.
I cannot seem to get this to compile…
function Update ()
{
if (TimeSlow.RemoveTimeSlow == true)
{
transform.position.y = -200;
Time.timeScale = 0.5;
yield WaitForSeconds (10);
Time.timeScale = 1;
}
}
Yield does not work within Update. You need a Coroutine.
sjj100
3
Ok thanks! I got it working with this…
function Update ()
{
if (TimeSlow.RemoveTimeSlow == true)
{
transform.position.y = -200;
PowerTime();
}
}
function PowerTime ()
{
Time.timeScale = 0.5;
yield WaitForSeconds (5);
Time.timeScale = 1;
}