I am making a simple jumping game and I have made a sphere which is going to be my power up. I want it so when I collide with the sphere, it sets the Time.timeScale to 0.5 for only 10 seconds. Then after the 10 seconds are up, it sets the Time.timeScale back to 1.
This is my current script:
function OnTriggerEnter ()
{
Destroy(gameObject);
Time.timeScale = 0.5;
}
Right now when I collide with it, it destroys the power up and set the Time.timeScale to 0.5, but I can’t figure out how to do this for only 10 seconds?
Any help or scripts appreciated!
Thanks so much! Will try the script out!
– EpicGamer928Tried out script but does exactly what my old script used to do. It doesn't turn the time scale back to 1 after 10 seconds. HELP!
– EpicGamer928Updated the answer, shouldn't have been destroying the object (because it stops the coroutine) until after the time out.
– whydoidoitIf you need it to be invisible for the time consider just moving it a long way at the start...
– whydoidoitThanks, I'll try it!
– EpicGamer928