- Home /
Screen.lockCursor messes my rotation
Hi,
I have implemented a camera which is child to a certain GameObject. To rotate my camera around the point I simply rotate this object around global X (up/down looking) and Y (left/right looking) axes. I'm using mouse for that - in my Update func i calculate deltaMousePosition - difference between current mouse position and the one from the frame before. I'm doing this only when I hit right mouse button. I additionaly wanted my mouse to be locked for the time-being, so I could rotate my camera endlessly (not being bothered by screen edges). Unfortunately when I do this, something strange happens. Camera jumps to some specific rotation and then it locks - does not rotate an inch.
I suspect, it is because now my deltaMousePosition is always equal 0. But if so, then how am I supposed to simultaneously calculate angles to rotate and have my mose locked?
Oh. Of course. Thanks. I forgot that there are Axes in Unity. You could post it as an answer, so I could accept it and give you some rep ;)
Haha okay, initially I only wrote one sentence and it felt too short to be an answer
Answer by Josh707 · Mar 23, 2014 at 01:45 AM
You can use Input.GetAxis to read mouse movement values without the position, by default they should be set up as "Mouse X/Y" in the input manager. Check out the Input class in the documentation for more info
Damn, I can't vote you up cause I have no rep at all... Sorry. $$anonymous$$aybe when I'll get this 15 rep I'll do this ;)
Your answer
Follow this Question
Related Questions
how to show cursor on specific time? 2 Answers
Hide and lock the mouse cursor (beginner) 0 Answers
Locking cursor/mouse on an object 1 Answer
Flight Sim Mouselook 1 Answer