- Home /
Hiding the cursor on a certain level. Pause Menu help.
I have three levels to my game, the title screen, the controls menu, and the actual game menu, and I'm trying to work off this scrip for a pause menu.
function Update () {
//hide the cursor (at the beginning of the game)
Screen.showCursor = false; }
My problem is that when I have this script attached, It takes the cursor away for all three levels, when I only want the cursor to be disabled for the game level. How do I make it so that the cursor is visible for the title, and the controls menu, but not the Game. Also, since this Is also being used for a Pause menu i'm trying to work on, I have another question.
How do I get two 3d textures to pop up when I press escape? also one last thing. I have a script that should make the cursor appear when the escape button is pressed, but I'm not sure what to attach it to.
var script = GetComponent("HideCursorScript");
script.enabled = false;
Answer by riko4628 · Mar 24, 2013 at 09:38 AM
What the cursor-hiding script is attached to? Try my script and attach it to the terrain or empty gameobject
function Start ()
{
Screen.showCursor = false;
}
function Update ()
{
if (Input.GetKey (KeyCode.Tab)) //when you press tab it will unlock the mouse
{
Screen.lockCursor = false; //the cursor is unlocked from center
Screen.showCursor = true; //cursor is visible
}
else
{
Screen.lockCursor = true; //the cursor is locked to center
Screen.showCursor = false; //cursor is invisibe
}
}
If this helped you please dont forget to press the like :)
V2:Press esc to unlock mouse from center and make it visible + lock camera movement, then press esc again to unlock.
private var isPaused = false;
function Update () {
Lock();
if(Input.GetKeyDown("escape") && !isPaused)
{
cursorlock = false;
isPaused = true;
GetComponent(MouseLook).enabled = false;
GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = false;
}
else if(Input.GetKeyDown("escape") && isPaused)
{
isPaused = false;
GetComponent(MouseLook).enabled = true;
GameObject.Find("First Person Controller").GetComponent(MouseLook).enabled = true;
}
}
function Lock () {
if (isPaused)
{
Screen.lockCursor = false;
Screen.showCursor = true;
}
if(!isPaused)
{
Screen.lockCursor = true;
Screen.showCursor = false;
}
}
Thanks for your response, Pressing Tab does work, but you have to hold it, this is for a pause menu, so I need the cursor to stay enabled until the player presses tab again, any ideas on how to...
pause the game the game showing the 3d textures (resume, and exit)
keep the cursor visible while the pause screen is up without having to hold tab.
Thanks again, mate.
Amazing! I can't thank you enough! I have one more thing that I need help with. When you press esc, how can I get two 3d textures to show up? I want a Resume and exit button. I know how to make the buttons take you to separate levels, but I don't know how to make them appear only when you press esc. like the cursor. Thanks again.
do you mean something like when you press esc the box will pop up?
Well, I mean, when you press esc, the pause menu opens showing resume, and end. how do I get the game to pause and show the buttons?
Answer by corriedotdev · Mar 24, 2013 at 02:17 PM
i agree with riko4628 , this is probs the best way to get around this.
Your answer
Follow this Question
Related Questions
add lockcursor to pause menu script?? 2 Answers
Pause menu doesn't pause everything 0 Answers
Script that makes the mouse cursor invisible. 3 Answers
Pause menu script, mouse not hiding 1 Answer
How to make a Main Menu 3 Answers