Pressing ‘escape’ key pauses the game without no issue. But it can’t be unpaused again. Neither the button in the panel nor pressing the ‘escape’ key again work… Game simply can’t be unpaused once it is paused. Following is the code… Any help is much appreciated. Thanks.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
public class PauseGame : MonoBehaviour {
public bool paused = false;
public GameObject thePlayer;
public GameObject pausedMenu;
void FixedUpdate () {
if (Input.GetButtonDown("Cancel")) {
if (paused == false) {
Time.timeScale = 0;
paused = true;
pausedMenu.SetActive(true);
thePlayer.GetComponent<FirstPersonController>().enabled = false;
Cursor.visible = true;
}
else {
thePlayer.GetComponent<FirstPersonController>().enabled = true;
paused = false;
pausedMenu.SetActive(false);
Time.timeScale = 1;
}
}
}
public void UnPauseGame() {
thePlayer.GetComponent<FirstPersonController>().enabled = true;
paused = false;
pausedMenu.SetActive(false);
Time.timeScale = 1;
}
}