EDIT: You're right, the key mapping was correct after all.
The second if statement needs to be an else if
. Now you're going through both if statements each time you hit p, effectively setting the boolean to true
and then immediately false
again.
Here's the working code:
function Update () {
if(Input.GetKeyDown("p")) {
if (!ispaused) {
Time.timeScale = 0;
ispaused = true;
} else if (ispaused) {
Time.timeScale = 1;
ispaused = false;
}
}
}