Game Development Reference
In-Depth Information
to enable following and orbiting, but the implementation of this is left as an exer-
cise for the reader.
First-person Camera
Withafirst-personcamera,thepositionofthecameraisalwaysasetverticaloffset
from the player character's position. So as the player moves through the world,
the camera remains at the player position plus the vertical offset. But even though
the camera offset doesn't change, the target location can change independently.
That's because most first-person games support looking around and turning while
not changing the physical location of the character. This configuration is shown in
Figure 8.10 .
Figure 8.10 First-person camera implementation.
The implementation for the rotation ends up being similar to the rotation of the
orbit camera; the main difference is that it is the target offset that's being rotated
instead of a camera offset. But there are some additional differences with this type
of camera. One is that when the target offset is rotated about the world up, the
avatar must also be rotated in the same manner. Another change is that typically
the pitch angle is limited to be no more than a certain value.
Duetothesemodifications,forafirst-personcamerait'scommontostorethepitch
and yaw as the total angles, as opposed to the delta amount per frame. This means
that the rotation will always be applied to the initial target offset, as opposed to an
Search WWH ::




Custom Search