Game Development Reference
In-Depth Information
else
// No real solutions, so they don't intersect
return false
end
end
Collision Response
We can use any of the preceding algorithms to determine whether or not two ob-
jects did, in fact, collide. But once they do collide, what should the game do? This
is the response to the collision. In some instances that response might be very
simple: One or both objects may die or be otherwise removed from the world. A
slightly more complex response might be something like a missile reducing the
health of an enemy on collision.
But what if the two objects need to bounce off of each other, such as two asteroids
colliding in Asteroids ? A tempting solution might be to simply negate the velo-
city of the asteroids upon collision. But a couple major issues crop up with this
approach. One issue is the asteroids getting stuck. Suppose there are two asteroids
that intersect on a particular frame, which results in their velocities being negated.
But what if they're travelling so slow that they still intersect on the next frame?
Well, their velocities will get negated again and again, frame after frame, and they
will be stuck in place. This is shown in Figure 7.13(a) .
Figure 7.13 Two asteroids get stuck (a), and the plane tangential to the point of
intersection (b).
Search WWH ::




Custom Search