Game Development Reference
In-Depth Information
Chapter 6. Events,
Triggers,
and
Explosions
Almost every game needs some form of event system that informs the game logic
about collisions that have occurred between objects, and many of these events are
triggered by invisible volumes of space that react when certain game objects enter
them. In this chapter, we'll learn how to build these features and then apply them by
simulating an explosion!
Building a collision event system
In a game such as Angry Birds, we would want to know when a breakable object such
as a pig or piece of wood has collided with something, so that we can determine the
amount of damage that was dealt, and whether or not the object should be destroyed,
which in turn spawns some particle effects and increments the player's score.
It's the game logic's job to distinguish between the objects, but it's the physics en-
gine's responsibility to send these events in the first place and then we can extract
this information from Bullet through its persistent manifolds .
Note
Continue from here using the Chapter6.1_CollisionEvents project files.
Explaining the persistent manifolds
Persistent manifolds are the objects that store information between pairs of objects
that pass the broad phase. If we remember our physics engine theory from Chapter
3 , Physics Initialization , the broad phase returns a shortlist of the object pairs that
might be touching, but are not necessarily touching. They could still be a short dis-
tance apart from one another, so the existence of a manifold does not imply a colli-
sion. Once you have the manifolds, there's still a little more work to do to verify if there
is a collision between the object pair.
Search WWH ::




Custom Search