|
Attractors/repulsors
Effective navigation assistance may be obtained by using attractors or
repulsors, where the camera is literally attracted to (or repulsed
from) pre-defined positions, regions, or other game objects. Often these positions
are defined explicitly using script objects that are placed by the camera
designer. Alternatively, offline analysis can be made of the environment to
determine automatic placement; in practice this can be a difficult prospect
without explicit rules governing their usage.
Both attractors and repulsors function by applying forces to the
camera depending on the proximity (and possibly orientation) of the player or
camera.
Note that these forces may not be implemented as part of the physical
simulation (even if such a facility is available); rather they may simply
influence the determination of the desired position or act as hard constraints
during the actual camera motion.
The use of proximity as part of the calculation of forces suggests that the attractor
or repulsor is spherical in nature, but this is not necessarily appropriate.
Cylindrical shapes are frequently the most useful, often with their major axis
aligned to the world up-vector.
Simplistic shapes are common because of the
relatively low cost in the calculation of the proximity of game objects, and
thus the forces required. Spheres, cylinders, and planes are common choices.
One specific example that is often problematic for cameras is navigation
through doorways, particularly if the character moves quickly. Other than the
problems of ensuring that the door does not physically close either between the
camera and its target or on top of the camera, doorways are frequently a
problem because they are often confined spaces and there are many opportunities
for the player character to move in ways that may cause the camera to be left
behind.
Vertical doorways are the most common case encountered, where the door
is aligned with the up-axis of the game world. Horizontal doorways have
additional challenges especially regarding camera orientation due to the
potential for gimbal lock. Additional problems occur when external
events may cause the door to close rapidly, leaving the camera behind the
closed door (or worse, interpenetrating the door geometry).
To cope with such
situations it is generally preferable that the door is held open while the
camera is on the opposite side compared to the player, but this is not always
possible. Thus, it is often necessary to implement a fail-safe to
ensure that the camera is never left on the wrong side of a closed door.
If the camera system is able to track the proximity of the camera to doorways
or otherwise be informed of how the camera is positioned and oriented relative
to the doorway (e.g., by means of a trigger volume), an axis-based attractor
may be used to help guide the camera motion through the doorway.
A proportional
attractor can apply forces to the camera dependent upon the camera position
relative to the axis of desired motion through the doorway. Care must be taken
to ensure that these forces do not impart oscillation and that they are only
applied when appropriate.
Considering the general case once again, the direction in which forces are
applied by attractors or repulsors is also variable. Common usage would have
the forces acting in relation to the physical shape of the attractor or
repulsors; for example, a spherical attractor would pull objects toward its
origin.
They can be based on a world-relative orientation; a cylindrical
repulsor may determine its force from the player character's proximity to the
central axis of the cylinder yet apply the repulsion force based on a fixed
world orientation.
Attractors and repulsors are sometimes attached to (or form part of) other game
objects. Thus, they may vary in their position and effects.
As with any force-based solution, care must be taken to ensure that such
objects only apply their forces when appropriate. Stout discusses this in
detail. Ensuring that forces do not adversely influence the camera is the most
difficult part of their usage.
Cameras do differ somewhat from AI objects in
this determination however, since there are additional aesthetic considerations
to consider (such as the requirement to ensure smooth motion whenever
possible). Thus if the camera incidentally moves past an attractor, it is not
necessarily appropriate that it should be influenced. If the camera were moving
away from the attractor, for example, we would not wish to apply any forces.
By careful choice of the attractor positions, camera motion can be made to
avoid geometry or pass through confined environments without the necessity for
complicated hand-scripted camera solutions. Indeed, the attractor or repulsors
can be combined with regular game objects (such as doors) to assist camera
motion without any additional scripting support.
|