I’m making a FPS coming out soon for mobiles. I have a pause menu and all that and it seems to be working fine. If i hit the pause button, everything around me freezes but i can still rotate the camera and my gun’s muzzle flash still appears when i hold down the LMB. Does any one know how to completely freeze the game so that it won’t accept any input unless you hit “Continue” or “Quit Game”? Heres my code :
var mainMenu : String;
var pausemenu : GUISkin;
var pauseButton : GUISkin;
private var pauseEnabled = false;
function Start(){
pauseEnabled = false;
Time.timeScale = 1;
AudioListener.volume = 1;
Screen.showCursor = false;
}
function Update(){
//check if pause button (escape key) is pressed
if(Input.GetKeyDown("escape")){
//check if game is already paused
if(pauseEnabled == true){
//unpause the game
pauseEnabled = false;
Time.timeScale = 1;
AudioListener.volume = 1;
Screen.showCursor = false;
}
//else if game isn't paused, then pause it
else if(pauseEnabled == false){
pauseEnabled = true;
AudioListener.volume = 0;
Time.timeScale = 0;
Screen.showCursor = true;
}
}
}
function OnGUI(){
GUI.skin = pausemenu;
if(pauseEnabled == true){
//Make a background box
GUI.Box(Rect(Screen.width /2 - 100,Screen.height /2 - 100,250,200), "");
//Make Continue button
if(GUI.Button(Rect(Screen.width /2 - 100,Screen.height /2 - 40,250,50), "Continue")){
pauseEnabled = false;
Time.timeScale = 1;
AudioListener.volume = 1;
Screen.showCursor = false;
}
//Make quit game button
if (GUI.Button (Rect (Screen.width /2 - 100,Screen.height /2 + 50,250,50), "Quit Game")){
Application.LoadLevel("mainMenu");
}
}
GUI.skin = pauseButton;
GUI.Box(Rect (Screen.width - 500,-5,100,50), "");
}
I’d appreciate it if anyone helps me out.