- Home /
Pause button not "caught" by pause script
I am sure I am just missing something extremely obvious here but my pause script doesn't seem to be catching a button press that my other scripts are. For example Here is a script I am using to just monitor controller input independent of the game.
if (Input.GetButton("Pause")) {
debugOUT.text += "\r\n" + "Pause: True";
} else {
debugOUT.text += "\r\n" + "Pause: False";
}
^ this works just fine. However my pause script doesn't seem to catch the button press at all.
void Update () {
if (Input.GetButtonDown("Pause")) {
Debug.Log("Pause!");
if (!isPaused) {
pauseTXT.gameObject.SetActive(true);
Time.timeScale = 0;
isPaused = true;
} else {
pauseTXT.gameObject.SetActive(false);
Time.timeScale = 1f;
isPaused = false;
}
}
}
I can't figure out why that second script doesn't seem to work at all. The button is obviously setup correctly in input manager since it can be caught from another script. This one just doesn't seem to catch it....
So I found that the issue is that Input.GetButtonDown("Pause") does not work but Input.GetButton works but does not function as I would like it to.
Here is how I have the button setup in the input manager
Answer by darthbator · Apr 15, 2013 at 04:34 AM
I just wanted to come back and give the correct answer in case this comes up on google for anyone. My issue was having it setup as an axis and not as a button. You can see the error in my screenshot. I actually realized it checking this thread for answers =P
Answer by Negagames · Apr 14, 2013 at 02:51 AM
Suggetion, try moving the whole if statement of "if(!paused)..." out of the GetButtonDown("Pause part"), and in the getbuttondown part put only:
paused = !paused;
p.s. Between the two scripts you used GetButton and GetButtonDown, could that have caused it?
Yeah I know about the different input grabs I made. That is because I don't want that loop running as long as the button is down but just during the first frame! I'm going to try fooling around with it once I get home! Thanks for the advice!
Oddly using GetButton works however GetButtonDown does not.... Why could this be?