- Home /
How setup Mouseook (set mouse position)
I'm working on a 3rd person camera, and want to achieve the "Mouse Look" effect. My script technically works, but it doesn't behave right behavior because I can't find a way to lock the cursor to a fixed point on the screen.
What I'm using now:
Vector3 oldMousePosition
1) Rotate camera by (currentMousePosition - oldMosePosition)
2) set oldMousePosition = currentMousePosition
3) Repeat
This works but not well... once the mouse approaches the edges of the screen, it's just not possible to rotate in that direction anymore. Sure, you can set it up so that you rotate only if a button is down. This way, you can move the mouse back to the center without rotating back, but the feel is terrible for the purpose and it's not at all fluid.
I want "True" mouse look:
1) Rotate camera by (currentMousePosition - windowCenter)
2) set mousePosition = windowCenter
3) Repeat
I know about Screen.lockCursor, and it sucks. It doesn't reset the mouse automatically, turning it true/false every Update or two causes the cursor to flicker, and it doesn't always put the mouse in the same place...
How can I set the mouse position myself, or at least get a decent mouseLook behaviour working? I'm using Unity Free. It's something that's so essential to a game that it's bizarre it seemingly can't be done : /
I figured it out : D
Had to use two external functions in User32.dll; SetCursorPos and GetCursorPos
Do you want to control the camera like in $$anonymous$$ouseLook, or to make the camera look to the direction you click?
Your answer
Follow this Question
Related Questions
setting the mouse position 2 Answers
How can I save MouseLook position in this script ? 0 Answers
Mouse position on 4.6 Canvas 0 Answers
How to make object fallow the mouse ?? 1 Answer
Mouse.position from center of player 1 Answer