682 12. Collision and Rigid Body Dynamics
z Some games allow the camera to move along an arc lying in a vertical
plane, perhaps described by a spline. This permits a single HID control
such as the vertical defl ection of the left thumb stick to control both the
zoom and the vertical angle of the camera in an intuitive way. (The cam-
era in Uncharted: Drake’s Fortune works this way.) When the camera comes
into collision with objects in the world, it can be automatically moved
along this same arc to avoid the collision, the arc might be compressed
horizontally, or any number of other approaches might be taken.
z It’s important to consider not only what’s behind and beside the camera
but what is in front of it as well. For example, what should happen if
a pillar or another character comes between the camera and the player
character? In some games, the off ending object becomes translucent ; in
others, the camera zooms in or swings around to avoid the collision.
This may or may not feel good to the person playing the game! How
you handle these kinds of situations can make or break the perceived
quality of your game.
z You may want the camera to react to collisions diff erently in diff erent
situations. For example, when the main character is not engaged in a
batt le, it might be acceptable to swing the camera horizontally to avoid
collisions. But when the player is trying to fi re at targets, both horizontal
and vertical camera swings will throw off his or her aim, so zoom may
be the only option.
Even aft er taking account of these and many other problematic situations,
your camera may not look or feel right! Always budget plenty of time for trial
and error when implementing a camera collision system.
12.5.3.8. Rag Doll Integration
In Section 12.4.8.7, we learned how special types of constraints can be used to
link a collection of rigid bodies together to mimic the behavior of a limp (dead
or unconscious) human body. In this section, we’ll investigate a few of the is-
sues that arise when integrating rag doll physics into your game.
As we saw in Section 12.5.3.6, the gross movements of a conscious char-
acter are usually determined by performing shape casts or moving a phantom
shape around in the game world. The detailed movements of the character’s
body are typically driven by animations. Game-driven rigid bodies are some-
times att ached to the limbs for the purposes of weapons targeting or to allow
the character to knock over other objects in the world.
When a character becomes unconscious, the rag doll system kicks in.
The character’s limbs are modeled as capsule-shaped rigid bodies connected