- Home /
Multiplayer pause menu won't disappear
Hello everyone.
I'm currently making a multiplayer tank game and i have come across a problem with the pause menu. When there are two or more users playing on the same server, one of them presses the "escape" key to bring up the menu. This works fine, however when clicking "Resume", the GUI window will stay open instead of disappearing ad the mouse cursor also stays visible, but locked.
If, however, a player is in the server on their own, the pause menu works fine. What could be the problem?
**Code for pause menu in progress:**
#pragma strict
function OnGUI() {
GUI.BeginGroup (Rect (Screen.width/2-175, Screen.height/2-75-50, 350, 150));
GUI.Box(Rect(0, 0, 300, 250), "");
if(GUI.Button(Rect(55, 10, 180, 40), "Resume")) {
Time.timeScale = 1.0;
var script3 = GetComponent(Pause);
script3.enabled = false;
var other : HideShowCursor;
other = gameObject.GetComponent("HideShowCursor");
other.on = true;
var other2 : MouseLook;
other2 = gameObject.GetComponent("MouseLook");
other2.on = true;
var other3 : MouseLook;
other3 = gameObject.transform.Find("CrateCamera").GetComponent("MouseLook");
other3.on = true;
}
if(GUI.Button(Rect(55, 100, 180, 40), "Quit")) {
Application.Quit();
}
GUI.EndGroup();
}
Code for "escape" to bring up pause menu:
#pragma strict
function Update () {
if(Input.GetButtonDown("Esc")) {
Time.timeScale = 0;
var paused1 = GetComponent(Pause);
paused1.enabled = true;
var other : HideShowCursor;
other = gameObject.GetComponent("HideShowCursor");
other.on = false;
var other2 : MouseLook;
other2 = gameObject.GetComponent("MouseLook");
other2.on = false;
var other3 : MouseLook;
other3 = gameObject.transform.Find("CrateCamera").GetComponent("MouseLook");
other3.on = false;
}
}
Thanks for your help.
Apologies for the poorly formatted code, I can't seem to get it positioned correctly in the question box.
I would have fixed it for you, but edits are not showing anymore.
Ah, thanks for trying though! $$anonymous$$uch appreciated