- Home /
Mouse lock
this is my script
Function Update () {
Screen.lockCursor
}
Im trying to lock the mouse in the center of the screen can anyone help me with this.
hey there is an example. i think you just missing " = true";
http://unity3d.com/support/documentation/ScriptReference/Screen-lockCursor.html
Answer by LegionIsTaken · Sep 18, 2011 at 03:16 PM
For optimization sake do it once every so often. I would do it in function Start
function Start (){
Screen.lockCursor = true;
}
Answer by dietclnp · Sep 18, 2011 at 02:10 PM
Screen.lockCursor is a bool, so you'll need to set it to true/false.
Also, you probably don't need to set it every time Update runs, consider doing it in Start() instead.
Dunno how it was in older version, but for reference, in 4.2.1f4 you HAVE to set it in Update, otherwise cursor will get free.
Fortunately bools are just one bit so it doesn't take much of processing power to set it.
Your answer
Follow this Question
Related Questions
Screen.lockCursor Acting Irregular 2 Answers
Cursor Problem / Toggle Lock and Unlock 0 Answers
Lock Mouse to the middle of the screen 1 Answer
Hide and lock the mouse cursor (beginner) 0 Answers
How to lock mouse? 1 Answer