- Home /
How can I change my script to un-pause my project?
Currently, I added a simple script consisting of a time.timeScale = 0.0 to pause my game when a keypress is initiated. I was wondering how to return the time.timeScale back to 1.0 using the same button.
...
This is what I came up with, and tried multiple things to un-pause it. I don't have an actual menu for pausing, it just stops all movement EXCEPT camera rotation (which I want to keep):
function Update () { if (Input.GetKeyDown ("escape")) { Time.timeScale = 0.0; } }
Answer by jeebxoxo · May 02, 2014 at 03:49 AM
Set a bool 'isPaused' to false. In C# it'd be like:
if (!isPaused) {
Time.timeScale = 0.0f;
isPaused = true;
}
else {
Time.timeScale = 1.0f;
isPaused = false;
}
I need it in Javascript. $$anonymous$$ixing C# and J-Script doesn't work with what I am supposed to be doing.
I know, I don't do anything in J-Script so I could only provide the C#. But J-Script wouldn't be any different though right? You add 'f' on to floats in C# which looks like you don't do for JS but the basic logic would be identical I think.
Your answer
Follow this Question
Related Questions
Incremental game need help 1 Answer
How to continue paused audio? Is there a special function? 1 Answer
Can't get Animation to stop 0 Answers