A six degree of freedom (6DoF) system describes one where a player is able to freely move along the X, Y and Z axis as well as yaw, pitch and roll their rotation. Unlike what you might encounter when rotating a player in a standard FPS when they can’t do flips in the air and are generally only allowed to fully rotate around the Y (up) axis a 6DoF game creates a few unique challenges. This prevents you from relying on something like Quaternion.Euler
because representing rotation in only 3 dimensions introduces the potential for gimble locking. Instead rotations need to be based on quaternion math - this enables you to rotate your objects freely without introducing unexpected behavior.
The basics of my 6DoF controller look like this:
|
|
The input
object is defined with this interface:
|
|
When multiplying two rotation quaternions together the right hand side of the operation is performed relative to the left hand side. This is why we use absolute angles here (Vector3.right
, Vector3.forward
instead of this.transform.right
and this.transform.forward
). More about this in Unity’s documentation or my video that covers using Unity Quaternion operators.
Gimble locking occurs when two or more of the axis of rotation align with one another causing the available rotations the object can take to be limited (multiple rotations cause the same overall effect on the object). You can learn more about this effect on Wikipedia: https://en.wikipedia.org/wiki/Gimbal_lock
I’ve been a big fan of 6DoF games since I was really young and draw a lot of inspiration from games like Descent, Overload and more. The style of games are really fun and I highly recommend giving one a try if you’ve never played one before.
Join the World of Zero Discord Server: https://discord.gg/hU5Kq2u