- Home /
Completely free moving camera script
I would like to make a script where moving the mouse left rotates the camera to the left, and moving it to the right rotates it to the right, and up makes you look up and down makes you look down, kind of like an airplane script, but I have no idea how to implement this and I do not want it with the Y axis up like most camera movement scripts, I want it to be completely free roaming (imagine you were in space in your airplane, so it move in every direction) I know there should be a simple way of doing this but I have yet to find an answer, any suggestions? Thanks! Logty
Answer by Waz · Sep 06, 2011 at 10:53 PM
You can't really get 3-axis rotation with a 2-axis mouse, for the obvious reason. If you don't give the player some sort of roll control (Q and E keys being a common choice), they'll just get annoyed by feeling constantly gimbal locked.
I won't down vote the question, since I'm sure others will ask the same invalid question, but rest assured, it is invalid.
hmmm... okay, thanks! Not the answer I wanted but it is the answer, I guess I'll have to accept it ;)!
Actually, I've seen more than a few 3d programs that try to induce 3 axis rotation with a mouse. I find it horribly annoying, see my new answer.
Certainly you can let the mouse produce rotations that end up as 3-axis rotations. The trouble is that at any given time the user can only change that rotation with 2 degrees of freedom, hence it's frustrating (so funny to watch people twist their mouse, expecting something to happen...
Answer by DaveA · Sep 06, 2011 at 10:14 PM
Maybe something like this? http://www.unifycommunity.com/wiki/index.php?title=FlyThrough
no, sorry, thanks for the idea! In my case the camera is already moving in a forward direction without any user input, and all you do is move your mouse up to rotate camera up, down for down, left to rotate camera left, and right to rotate camera right
Answer by EricD · Sep 07, 2011 at 06:01 PM
Use the Wii remote control incl. motion plus. That way you can use the gyroscope to directly move a camera.
Answer by DaveA · Sep 07, 2011 at 06:04 PM
If you want to fly like an airplane, and you have a 'joystick' with two axis (for turn left/right, pitch up/down), then like Warwick says, you need a 'roll' somehow. That either means using another input, or you can auto-roll (bank). Google banking algorithms or have fun with the math. For an airplane you might want it based on Newtonian physics, but for a space ship you may be able to fake it.