I’m kind of a programming noob, but my knowledge should be good enough to get this simple game I’m trying to make done.
So my question is that I have a pause menu, a GUI appears and I want to be able to click a button and things will happen.
When you press escape, the game pauses just fine, and when you press escape it un-pauses. I also want to be able to click the continue button to un-pause the game.
I have a script for the continue button that references the “Is paused” paused variable and i want to set it to false, like this:
function OnMouseDown ()
{
GameObject.Find("Main Camera").GetComponent(Pause).pauseGame = false;
}
but it doesn’t seem to be working.
Here is the script for my pause interface:
public var pauseGame : boolean = false; //the variable I'm trying to access
public var showGUI : boolean = false;
public var optionsMenu : boolean = false;
function Start()
{
Screen.lockCursor = true;
}
function Update ()
{
if(Input.GetKeyDown(KeyCode.Escape))
{
pauseGame = !pauseGame;
if(pauseGame == true)
{
Time.timeScale = 0;
pauseGame = true;
GameObject.Find("Main Camera").GetComponent (MouseLook).enabled = false;
GameObject.Find("Main Camera").GetComponent (ColorCorrectionCurves).enabled = true;
GameObject.Find("Main Camera").GetComponent (NoiseAndGrain).enabled = true;
GameObject.Find("First Person Controller").GetComponent (MouseLook).enabled = false;
GameObject.Find("Crosshair").GetComponent(GUITexture).enabled = false;
Screen.lockCursor = false;
showGUI = true;
}
else if(pauseGame == false)
{
Time.timeScale = 1;
pauseGame = false;
Screen.lockCursor = true; //Not relocking!
GameObject.Find("Main Camera").GetComponent (MouseLook).enabled = true;
GameObject.Find("Main Camera").GetComponent (ColorCorrectionCurves).enabled = false;
GameObject.Find("Main Camera").GetComponent (NoiseAndGrain).enabled = false;
GameObject.Find("First Person Controller").GetComponent (MouseLook).enabled = true;
GameObject.Find("Crosshair").GetComponent(GUITexture).enabled = true;
showGUI = false;
}
}
}
If anyone can help me that would be wonderful!
ALSO: I’m having trouble with my mouse lock command. The mouse unlocks just fine when I go to pause, but it doesn’t relock when I un-pause the game, and I need it to go back to being hidden and locked.