Game Development Reference
In-Depth Information
M 1
M 2
M 1
M 2
M 1
M 2
M 2
M 1
Figure 12.12
Examples of the types of results returned
by collision detection.
consider a game with a kick mechanic. It may be helpful to treat a kick
as a “collision” with an object, even if the character's foot is not in the
physics system or if this collision was determined by simple proximity tests
or raycasting that were designed based on gameplay goals and not reality.
(The player character may have been too far away or too close for the kick to
really have hit the target; but that is irrelevant.) It might be highly useful
for the response to this action to be handled in a manner similar to ordinary
collisions. For example, a sound and particle effect plays, the object receives
a reduction in hit points, and its visual appearance changes, etc. In this
case, in order to use the same collision response code for both ordinary
collisions and “virtual” collisions such as player kicks (even if it is just to
get the cosmetic effects right), you may need to synthesize values ordinarily
provided by the collision detection system for your “virtual” collisions, such
as the mass and velocity of the foot, and the point of contact and surface
normal.
One final caveat is that we are concerned only with linear momentum
for now; our objects do not rotate. This means that the explanation we
give in this section will be incomplete. However, it will be helpful to cover
the general principles here in a context free of the extra complexity that
comes with rotation.
Now to the heart of the matter. Assuming we have somehow detected a
collision and obtained a position and normal, how do we determine the re-
sulting velocities for the collision response? Here we show the usual method,
following an article by Chris Hecker [34]. We start by reviewing our guiding
principles.
 
Search WWH ::




Custom Search