- Home /
Lock the screen
Hola I want to be able to lock the screen when i press the Q key on my keyboard but still be able to move the cursor around. Then when I press the Q key again the game goes back to normal. I have found very little info on this, I found lots of stuff to hide the cursor but that is not what i need. I do not know much about code I have no idea where to start I know I need to set up a key to stop the screen from moving but i can't figure out how to write in code "hey camera stop you making me dizzy I want to push that button stop moving cause i move the cursor" I play a demo that does this like i want with an inventory system added, I need inventory system too you know but I try to take that code apart just to get the camera stuff and got error this and error that. you don't have to write code for me just show me what does what you know like steps, do this then this then that and boom no more crazy camera. grasias from Mexico your brothers from another mother. adios amigos
I use this script makes camera stop but i lose cursor too, i want to freeze camera movement but still use cursor here is script I use. muchas grasias
private var fpc$$anonymous$$ouse; private var cam$$anonymous$$ouse;
function Start () {
fpc$$anonymous$$ouse = gameObject.Find("First Person Controller").GetComponent("$$anonymous$$ouseLook"); cam$$anonymous$$ouse = gameObject.Find("$$anonymous$$ain Camera").GetComponent("$$anonymous$$ouseLook");
}
function Update () {
if (Input.GetButtonDown ("Fire2")) { Screen.showCursor = !Screen.showCursor; fpc$$anonymous$$ouse.enabled = !fpc$$anonymous$$ouse.enabled; cam$$anonymous$$ouse.enabled = !cam$$anonymous$$ouse.enabled; }
}
Answer by Koboh Z · Nov 10, 2010 at 03:11 PM
grasias to all wonderful people who post here i found the info and was able to figure out how to do it!!!!! here is the script
private var fpcMouse; private var camMouse;
function Start () {
fpcMouse = gameObject.Find("Player").GetComponent("MouseLook"); camMouse = gameObject.Find("Main Camera").GetComponent("MouseLook");
}
function Update () { if (Input.GetKeyDown(KeyCode.Q)) {
Screen.showCursor = !Screen.showCursor;
Screen.showCursor = true;
fpcMouse.enabled = !fpcMouse.enabled;
camMouse.enabled = !camMouse.enabled;
}
}
for anyone who might need it. to use make a game object you know one of them invisiable cubes then place this script in it and BOOM no more crazy camera. the current key is Q but you can change it. Might not be the way to do it but it stops the crazy camera.