Eric King's Advanced Games

 

Quaternion Camera

This assignment involved building a quaternion-based camera with a custom quaternion, which was used to replace Unity's quaternion class.

This camera has two modes, track mode and free mode. Initially, the camera is in track mode, which allows the user to move a cube through the world while the camera follows it. Also, the camera auto-zooms towards the cube if another object is blocking the center of the viewport. Use WASD to move the cube, and move the mouse to orbit the camera around the cube. Right-click to switch to free mode.

In free mode, the camera is detached from the cube and is not affected by any objects. Use WASD to move the camera, and move the mouse to rotate. Right-click to return to track mode.

Run the web player to see the quaternion-based camera in action. Some source code is also provided. The Quaternion struct is the type that replaced Unity's. The ThirdPersonController uses quaternions to move the cube. Lastly, the QuaternionCamera uses quaternions to maneuver the camera.

Play webplayer

Download Quaternion struct

Download ThirdPersonController script

Download QuaternionCamera script