Game Development Reference
F IGURE 17.1
Data flow through the physics engine.
Setting up new objects with the correct physics can be a challenge. In my experi-
ence it is invaluable to have a simple environment set up as part of the level-design
process where the physics of objects can be tested interactively. That way, as you de-
velop you can be sure that the object feels right in its environment and that no crucial
data is being left uninitialized.
U SING THE P HYSICS E NGINE
We can now do almost anything we want with our physics engine. In this chapter I'll
give you a taste of some of the most popular applications for physics: ragdolls, break-
able objects, and movie-style explosions. On the way we'll look at some additional
techniques, force generators, and ways to configure the engine.
There is one important caveat to these applications, however. If you are building
your engine for a single purpose (to run off-road trucks or as part of a procedural
animation system, for example), then there may be faster ways to get there directly.
I am going to focus on using our generic engine to power these effects. If all you
need is a single-purpose physics system, there may be things we have put in our code
that aren't needed. For example, for high-spec racing cars that don't normally leave
the ground, you can omit all the rigid-body physics and build special-case spring code
to model how their suspension flexes and how it handles.
Our approach is to build a physical approximation of the object and simulate
it. Sometimes a better approach is to work out the desired behavior and program
that in explicitly. Having said that, the general-purpose versus special-case dilemma
is becoming increasingly moot. Modern games typically need several effects at once: