Hi, my pause menu isn’t working at all, I’ve followed someone’s code to try and get it working and it just won’t work at all, I hit pause and the menu pops up but I can still look about and move the camera around, what is wrong with my code?
I also get this error message “NullReferenceException: Object reference not set to an instance of an object PauseScript.Update () (at Assets/MyFolder/My Scripts/PauseScript.js:27)”
#pragma strict
var pauseCanvas : Canvas;
var isPause = false;
function Start()
{
Screen.lockCursor = true;
Cursor.visible = false;
}
function Update()
{
if( Input.GetKeyDown(KeyCode.Escape))
{
isPause = !isPause;
if(isPause)
{
Time.timeScale = 0;
pauseCanvas.enabled = true;
}
else
{
Time.timeScale = 1;
pauseCanvas.enabled = false;
}
(gameObject.Find("First Person Controller").GetComponent("MouseLook") as MonoBehaviour).enabled = false;
(gameObject.Find("Main Camera").GetComponent("MouseLook") as MonoBehaviour).enabled = false;
pauseCanvas.enabled = true;
Time.timeScale = 0;
Screen.lockCursor = false;
Cursor.visible = true;
}
}
function ResumeGame()
{
}