Game Development Reference
In-Depth Information
A physics system should be able to stream so that you can save and load its state.
Even if your game doesn ' t have a load/save feature, it is likely that your game editor
has a save feature; otherwise, it wouldn
t be much of a game editor. In many game
editors, physics objects are placed in the level and simulated until they find a stable
position. Usually, you
'
d do this for candles sitting on tables and other props, but you
could do it for something as complicated as a stone bridge. It might be fun to blow
up something like that in your game! Either way, you can
'
'
t count on designers to
place the objects with such accuracy, so it
'
s best to let the physics system simulate it
until it stabilizes and then save the state.
Now that you
'
ve acquired a physics SDK with everything on your checklist, let
'
s talk
a little about how to actually use it.
Object Properties
Physical objects have properties that affect their movement and interactions with
other objects. We
ve already talked about mass, position, velocity, force, the inertia
tensor, angular velocity, and torque. These properties describe object motion under
force in free space. When objects bump into each other or into infinitely heavy
objects, their reactions are dependent on three more properties: restitution, static fric-
tion, and dynamic friction.
Restitution is the amount of bounce that an object has when it hits something and is
usually expressed in a positive floating-point number. A good way to think of this is
how high a ball will bounce when you drop it. If the restitution is 0.0f, you ' ve got a
piece of playdough, and when it hits it will simply stick to the ground. If you
'
'
ve got
something like 0.99f, you
'
ve got a nice superball that will bounce around for a long
time. It
s a bad idea to assign restitutions of greater than 1.0f, since the object will
simply continue to gain energy forever.
Static friction and dynamic friction describe how much energy is lost when two
materials are in contact and at rest or are in relative motion. Oddly enough, friction
changes drastically in these two conditions. This is why it ' ssohardtoregaincon-
trol of a car once it
'
the dynamic friction is lower than the static fric-
tion. You experience this same issue when pushing heavy objects; it
'
sinaskid
seasiertokeep
them moving than it is to get them moving initially. Note that most physics imple-
mentations support only a single coefficient of friction and don
'
'
t accommodate
both types.
The coefficient of friction, usually represented by
, is a number that is calculated by
the ratio of the force (F) required to move an object over the normal force (N), which
 
 
Search WWH ::




Custom Search