Hello, I've been trying to figure out how to replicate a movement of a ship like in the game Descent 1. What I understand is that it is a 6 DOF camera and they have some sort of auto-leveling implemented.
Right now I have 6 DOF movement in my game, but I cannot figure out how to get the ship to align to the up vector on each axis. For instance with this code:
This code will not align my ship properly in all rotations performed by the mouse. Is there some way to get this ship to align to the walls of my level no matter the rotation of the ship?
I'd appreciate any help, thanks.
Won't do anything meaningful. The x, y, and z elements of the quaternion don't correspond to angles, and mixing and matching elements from different quaternions like that will just produce a more or less random result in the general case. (It might work out in some cases, but if so, it's just circumstantial.)
Is close, except it needs to be:
This will align the object instantly to the surface normal. If you want the alignment to be more gradual, you can use Quaternion.Slerp() instead.
answered Mar 27 '11 at 06:08 AM