Game Development Reference
In-Depth Information
this particular style of collision event management; one where we only recognize the
collision and separation events.
If we wanted objects to remember that they're still touching something, we would
have to introduce some internal method of counting how many objects they're still in
contact with, and incrementing/decrementing the count each time a collision or sep-
aration event comes along. This naturally consumes a little memory and processing
time, but it's certainly far more optimized than the alternative of spamming a new col-
lision event every step while two objects are still touching. We want to avoid wasting
CPU cycles telling ourselves information that we already know.
The CollisionEvent() and SeparationEvent() functions can be used by a
game logic to determine if, when, and how two objects have collided. Since they
hand over the rigid bodies involved in the collision, we can determine all kinds of im-
portant physics information, such as the points of contact (where they hit), and the
difference in velocity/impulse force of the two bodies (how hard they hit). From there
we can construct pretty much whatever physics collision-related game logic we de-
Try picking up, or introducing more objects with the left/right mouse buttons,
causing further separations and collisions until you get a feel for how this system
Search WWH ::

Custom Search