- Home /
how to pause the mouselook script during pause?
i have a C# script to pause my game. it works fine exept that the mouse look is still on, so when im using my mouse to select a option on the menu, the first person camera is still looking around.
how do i pause the mouse look script?
here is my code:
`using UnityEngine; using System.Collections;
public class PauseMenu : MonoBehaviour { public GUISkin myskin;
private Rect windowRect;
private bool paused = false , waited = true;
private void Start()
{
windowRect = new Rect (Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 200);
}
private void waiting()
{
waited = true;
}
private void Update()
{
if (waited)
if (Input.GetKey(KeyCode.Escape) || Input.GetKey(KeyCode.P))
{
if (paused)
paused = false;
else
paused = true;
waited = false;
Invoke("waiting",0.3f);
}
if (paused)
Time.timeScale = 0;
else
Time.timeScale = 1;
}
private void OnGUI()
{
if (paused)
windowRect = GUI.Window (0, windowRect, windowFun, "pause Menu");
}
private void windowFun(int id)
{
if (GUILayout.Button("Resume"))
{
paused = false;
}
if (GUILayout.Button("Options"))
{
}
if (GUILayout.Button ("Main Menu"))
{
Application.LoadLevel ("Menu");
}
}
}`
try this:
private $$anonymous$$ouseLook mouseL;
void Start () {
mouseL = the game object.GetComponent<$$anonymous$$ouseLook>();
}
void Update () {
if (paused) {
mouseL.enabled = false;
} else {
mouseL.enabled = true;
}
}
Answer by louddifference · Aug 05, 2014 at 03:30 AM
try this:
private MouseLook mouseL;
void Start () { mouseL = the game object.GetComponent(); }
void Update () { if (paused) { mouseL.enabled = false; } else { mouseL.enabled = true; } }
it says unexpected symbol 'game', what do i change it to?
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Pause Menu open/close on key 1 Answer
Game stopping at Pause? 1 Answer
Script Not workin 1 Answer
Zelda like pause menu 1 Answer