- Home /
 
               Question by 
               alpheus125 · Mar 20, 2012 at 01:23 AM · 
                javascripttimepausetimescale  
              
 
              Pause button
I am trying to make a button (LeftAlt) that will set the timeScale to 0 and show/unlock the cursor but my script isn't working, here is my script (JavaScript):
 var p = 0;
 function Update () {
 if (Input.GetKeyDown(KeyCode.LeftAlt) && p == 0)
 {
 Time.timeScale=0;
 Screen.showCursor = true;
 Screen.lockCursor = false;
 p = 1;
 }
 if (Input.GetKeyDown(KeyCode.LeftAlt) && p == 1)
 {
 Time.timeScale=1.0;
 p=0;
 }
 
 }
               Comment
              
 
               
              Answer by DaveA · Mar 20, 2012 at 01:25 AM
 p = 1;
 }
 if (Input.GetKeyDown(KeyCode.LeftAlt) && p == 1)
That's going to set p to 1 then check that p == 1
 var p = 0;
 function Update () {
 if (Input.GetKeyDown(KeyCode.LeftAlt))
 {
   if (p == 0)
   {
    Time.timeScale=0;
    Screen.showCursor = true;
    Screen.lockCursor = false;
    p = 1;
   }
   else
   {
    Time.timeScale=1.0;
    p=0;
   }
 
 }
Your answer
 
 
             Follow this Question
Related Questions
Pause menu... Isn't pausing everything... 1 Answer
How to Appease a pause menu in a game that changes it's time scale? 1 Answer
TimeScale = 0 crashes Unity 1 Answer
Pause, Unpause 1 Answer
Problem changing TimeScale 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                