Wednesday, April 8, 2015

Game Camera Types

Before diving in to details I'd like to define some camera types. The names I use for these cameras are likely different from what other teams use since there isn't a lot of academic literature for this subject.

Each camera type has specific utilities, such as walking, following a vehicle or fitting in small spaces. When the utility of a camera fits the space and gameplay the camera will be out of the way. Each type can be implemented in a number of ways. There are a number of parameters that camera systems manage but these definitions relate specifically to orientation and target distance. Each camera type may have collision logic or variable field of view. In this post the camera has a position and orientation and the camera target is something the camera is tracking that has a position and a facing direction.

I will find some way to draw clear lines and arcs to illustrate these camera types in a future post. For now I hope the written definitions are clear.

Leash Camera

This type of camera is best suited to follow a target that moves at moderate speed and allows for full user control. The idea is to keep the distance between the camera and the target constant but both the rotation around the vertical axis (yaw) and translation minimal.

The algorithm is as simple as the definition:

Before moving the camera position, rotate it towards the (update) target point and then move the camera towards or away from the target to correct the camera distance.

The result is a camera that minimizes movement and rotation while still gradually making the camera face the direction of gameplay.

Vehicle Camera

With fast moving physics driven camera targets there is a specific direction to focus at and leaving too much to user control gets in the way of the game. Depending on the style the direction of focus will be the the facing direction of the vehicle or the direction of the velocity or something in the middle.

The logic for this camera is trivial, pick a direction from the target facing or target velocity and stick the camera at the desired distance. This camera typically requires some smoothing of the direction.

This camera shows the user what is coming up without the user worrying about aiming the camera.

Aiming Camera

The use of the aiming camera is usually more limited and more user controlled than other cameras. The aiming camera simulates the targeting direction of a ranged weapon and usually requires that the player is strafing (player facing in the direction of the camera but not necessarily moving in the facing direction).

Unless the camera is at the barrel of the weapon the weapon generally follows the facing direction of the camera. The direction is user controlled and to minimize the camera translation it is better to keep the camera close to the target.

Whatever is at the center of the screen is the aiming target.

Fixed Direction Camera

This camera type doesn't rotate by itself and may have user control disabled. Side view cameras in 3D games is a specific version of a Fixed Direction Camera.

Spline Cameras

Every 3D game I've worked on have had some use of Bezier splines, but how the camera uses the spline is varied. The most common suggestion is to treat the camera as a leash camera but then move the camera to the closest point on the spline.

Implementations include finding the closest point from the target to a spline and putting the camera at an offset from the spline point, or finding a spline point near the target and matching that with a point on a second spline where the camera is placed.

A surprisingly well working spline camera finds a point on a spline near the target position and rotates the camera to face along the spline with the same speed as the camera would have rotated as a leash camera.

No comments:

Post a Comment