- Home /
Using pre-made script to pause Mouselook X axis not pausing
I read about a refined Pause Script here: http://answers.unity3d.com/questions/60236/how-can-i-pause-the-mouse-look-script-when-i-pause.html
and managed to implement it into my game (First game with Unity might I add) and it works great except for one problem. I can access the MouseLook that affects the Y axis, and set it on and off, but I can't seem to do the same for the X axis version, I keep receiving a Null Pointer Error. If I uncomment any of the three lines commented out, I receive that error and the Y axis doesn't get paused as well at that point. If I comment it out, the Y axis pauses alone.
Here's the rest of the code if you want to see it for reference:
function PauseGame()
{
savedTimeScale = Time.timeScale;
doPauseWindow = true;
Time.timeScale = 0;
AudioListener.pause = true;
//firstPersonControllerCamera = gameObject.Find("First Person Controller").GetComponent("MouseLook");
mainCamera = gameObject.Find("Main Camera").GetComponent("MouseLook");
//firstPersonControllerCamera.enabled = false;
mainCamera.enabled = false;
if (pauseFilter)
{
pauseFilter.enabled = true;
}
}
function UnPauseGame()
{
Time.timeScale = savedTimeScale;
doPauseWindow = false;
AudioListener.pause = false;
//firstPersonControllerCamera.enabled = true;
mainCamera.enabled = true;
if (pauseFilter)
{
pauseFilter.enabled = false;
}
}
Answer by moinchdog · Dec 03, 2012 at 07:32 AM
try placing AudioListener.pause in function UnPause on Pause.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Cursor Lock to Center of screen script doesnt work please help. 2 Answers
Pause Audio Help 1 Answer
pause menu on android phone 1 Answer
Script to disable MouseLook? 2 Answers