Hello I’m having some trouble with a pause and pause menu script I’m working on. The scripts themselves work fine but when I test the game the pause menu opens up straight way, without being prompted. Although this happens the resume button is fully functional and I can open and close the pause menu without any trouble.
Also upon triggering the pause menu the game itself doesn’t pause at all, instead the character continues going forward and passes straight through any other gameobjects as though a collider isn’t there.
Here are the scripts, attached to the main camera:
function Update () {
if(Input.GetKey("escape")) {
Time.timeScale = 0;
var script3 = GetComponent("PauseMenuScript");
script3.enabled = true;
}
}
and
var newSkin : GUISkin;
function thePauseMenu() {
GUI.Box(Rect(250, 150, 300, 350), "Pause Menu");
if(GUI.Button(Rect(310, 190, 180, 70), "Resume")) {
Time.timeScale = 1.0;
var script3 = GetComponent("PauseMenuScript");
script3.enabled = false;
}
if(GUI.Button(Rect(310, 290, 180, 70), "Music")) {
Application.LoadLevel(3);
}
if(GUI.Button(Rect(310, 390, 180, 70), "Main Menu")) {
Application.LoadLevel(0);
}
}
function OnGUI () {
GUI.skin = newSkin;
thePauseMenu();
}
thePauseMenu();
I don’t know where I went wrong. Thank you for any answers or feedback. - Ben