- Home /
Is there a way to lock the cursor while still detecting mouse movement?
I have a first person camera (I'm using my own first person controller script), but when the player moves the mouse to the edge of the screen, they are unable to rotate the camera anymore, since the camera is based on mouse movement. Is there anyway to prevent this, such as allowing the cursor to wrap around the screen, or by locking the cursor to the center of the screen?
Answer by timohausmann · Jul 16, 2015 at 01:47 PM
Check out http://docs.unity3d.com/ScriptReference/Cursor-lockState.html
Cursor.lockState = CursorLockMode.Locked;
You should still be able to detect Mouse Movement via Input.GetAxis("Mouse X")
& Input.GetAxis("Mouse Y")
. http://docs.unity3d.com/ScriptReference/Input.GetAxis.html
Your answer
Follow this Question
Related Questions
Cursor not getting centered 0 Answers
Mouse Cursor Problem 2 Answers
Particle Emitter from moving object to cursor location 1 Answer
Moving forward towards the cursor with LookAtMouse? 0 Answers
Error with mouse cursor. 1 Answer