I’d like to have two keys pause the game. The “p” and “Escape” keys to be specific.
The script below is working for both of these, but I’m sure it’s double the amount of script necessary, and so I’d like to know how I can have both keys mentioned in the first if statement?
This my first UnityAnswers question, so please let me know if I have not been clear enough.
//Pause the game with the "P" key
if(Input.GetKeyDown("p") && paused == false)
{
paused = true;
Time.timeScale = 0;
}
else if(Input.GetKeyDown("p") && paused == true)
{
paused = false;
Time.timeScale = 1;
}
//Pause the game with the "Escape" key
if(Input.GetKeyDown(KeyCode.Escape) && paused == false)
{
paused = true;
Time.timeScale = 0;
}
else if(Input.GetKeyDown(KeyCode.Escape) && paused == true)
{
paused = false;
Time.timeScale = 1;
}
Thanks very much, that's great
– alecchalmers