- Home /
How to disable Mouse Look On Pause Menu.
Hi Guys... My Game has a pause menu "Press Escape In Game It Pauses" But if you move the mouse around to select options/quit/resume etc the actual scene in BG moves since mouse look is enabled... Is there a way to find the Firstperson controller prefab and disable the mouse look script and then on resume re enable it?
Answer by PedramAUS · Feb 17, 2013 at 09:12 AM
You can also enable and disable the scripts as you suggested.
private void DisableMouseLook(bool enable)
{
GameObject FPC= GameObject.FindWithTag("Player");
FPC.transform.GetComponent<CharacterMotor>().enabled = enable;
FPC.transform.GetComponent<MouseLook>().enabled = enable;
Camera.mainCamera.GetComponent<MouseLook>().enabled = enable;
}
To stop the player to move using arrow keys, you can disable the CharacterMotor script as well.
It is assumed that the first person controller's game object is tagged as "Player". If not you can also find the object by its name.
Answer by ShadowAngel · Feb 17, 2013 at 08:48 AM
Go to mouse look script and add if check on top of all update function: if (!pause) { mouse look update script here } now in Start function add public var named pause and type boolean.
Thats it, evrything you need now is to change pause var to true whenever your game on pause.