Hide Cursor

Hi everyone.

I’m using this new brand JS;

private var showingCursor = false;

function Start(){

Screen.showCursor = false;

}

function Update(){

if(Input.GetKeyDown("escape")){

    if(showingCursor == true){
    Screen.showCursor = false;
    showingCursor = false;
    }

    else if(showingCursor == false){
    Screen.showCursor = true;
    showingCursor = true;
    }
}

}

I works fine, but how can i freeze the game when i press “escape”.?

The game should freeze untill i press the “escape” key again.?

Somone can help me?

It depends what you want to do in the game…

try this script:

    private var showingCursor = false;

function Start(){

Screen.showCursor = false;

}

function Update(){

	//check if pause button (escape key) is pressed
	if(Input.GetKeyDown("escape")){
	
		//check if game is already paused		
		if(showingCursor == true){
		Screen.showCursor = false;
		showingCursor = false;
		Time.timeScale = 1;
		AudioListener.volume = 1;
		}
		
		//else if game isn't paused, then pause it
		else if(showingCursor == false){
		Screen.showCursor = true;
		showingCursor = true;
		Time.timeScale = 0;
		AudioListener.volume = 0;
		}
	}
}

This is part of a script that I have written for a pause menu.

What it does is when the player presses a key (i’ve made it escape but you can change it), then it shows the mouse pointer. Then if they press the same button again, it goes away…

Hope this is what you were looking for!!! :smiley:

-Grady