- Home /
This question was
closed Jan 23, 2014 at 09:20 AM by
fafase for the following reason:
Duplicate Question
turn off script with a key..
hey i have a script that locks the mouse i need the script to turn off when i press escape then turn back on when i re press it, the escape button is what gets me into the menu... the script i have it... any ideas?? or re writes to it... to fix my issue
function Update () {
Screen.showCursor = false;
Screen.lockCursor = true;
Screen.lockCursor = false;
}
var paused : boolean = false;
function Update ()
{
if(Input.GetKeyDown("escape")
{
paused = !paused ;
if(paused) //Do Stuff When Paused
{
Screen.showCursor = true;
}
else // Do stuff when unpaused
{
Screen.showCursor = false;
}
}
}
Comment
Answer by jaroosh · Jan 23, 2014 at 09:13 AM
first of all you have 2 Update methods in one script which wont work, I think what you wanted to do is :
function Start() {
Screen.showCursor = false;
Screen.lockCursor = true;
Screen.lockCursor = false;
}
and here : if(Input.GetKeyDown("escape") youre missing a closing ')' bracket so it should be :
if(Input.GetKeyDown("escape"))
and it should work :)
Follow this Question
Related Questions
Pick up key and unlock a locked door 1 Answer
Mouse locked in center 1 Answer
menu issue and mouse click 0 Answers
Screen.lockCursor not working? 3 Answers