First Person Shooter Cameras

In this article I’ll be covering the concepts and what level of math knowledge is required for making a First-Person Shooter (FPS) Camera in games. So let’s get started with some common concepts: pitchyaw, and roll. Pitch is when the player moves the camera up and down. Yaw is when the player moves the camera from left to right and respectively. And finally Roll is when the player tilts the camera from left to right and respectively,  this rotation usually occurs around the Z-axis.

Camera movements using the computer mouse (Pitch, Yaw and Roll)

The FPS Camera functions

In FPS games, the is camera required to do the following:

  • Move forward and backward (Using the W or S keys on the keyboard)
  • Strafe Left or Right (Using the A or D keys on the keyboard)
  • Jump (Using the [space] key on the keyboard)
  • Look around (Using the mouse):
    Pitch (Look up and down), Yaw (Look left or right) and Roll (Tilt left or right)

Camera movements using the computer keyboard

 

Advanced Mathematics knowledge is required to make an FPS camera

As you already know, all kind of programming will require some mathematics knowledge. However, game programming is a challenging level of programming, and the mathematics required here, goes usually beyond what the average person knows, with other words even the math becomes challenging in the way it is required to be used. Here’s how the axis are used for an FPS camera:

Vectors used to describe the position and orientation of the camera in the world

The picture above describes the Euler Angles, and are based on Euler’s Rotation Theorem that any rotation can be described using three angles (X, Y, Z). Another mathematics formula or method to be applied here is Matrix, no I am not referring to Matrix the movie. The matrix in game development is often described as view matrix.

 

The Matrix

In addition to what has been covered so far, you also need the following skills: GeometryTrigonometry (You only need: sin and cos), Vectors, Matrices, 2D and 3D transforms, Projections, and Transformations between coordinate systems. However, please note that I cannot teach you math here, but I will later post a complete tutorial on how to make your own FPS camera with C++ and we will either be using OpenGL or DirectX.

 

References:
Weisstein, Eric W.
 “Euler Angles.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/EulerAngles.html
Weisstein, Eric W.
 “Euler’s Rotation Theorem.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/EulersRotationTheorem.html
Weisstein, Eric W.
 “Matrix.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Matrix.html
Weisstein, Eric W.
 “Trigonometry.” From MathWorld–A Wolfram Web Resource.
http://mathworld.wolfram.com/Trigonometry.html
Weisstein, Eric W.
 “Sine.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Sine.html
Weisstein, Eric W.
 “Cosine.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Cosine.html
Weisstein, Eric W.
 “Geometry.” From MathWorld–A Wolfram Web Resource. http://mathworld.wolfram.com/Geometry.html
Vector: http://content.gpwiki.org/index.php/Vector

Leave a Reply