Game Development Reference
In-Depth Information
on a flat surface is simply the mass of the object multiplied by the acceleration due to
gravity:
F ¼ μ N
μ ¼ F=N
So if it took a 700N force to move an object that weighed 100Kg (thus exerting a
980N force on whatever surface it was sitting on), the coefficient of static friction
would be about 0.714f. Once the object was moving, if all you had to apply was
490N to keep it moving at a steady speed, the coefficient of dynamic friction (or slid-
ing friction) would be 0.5f.
Intuitively, the friction between two objects has everything to do with what those
objects are made of. Many physics systems let you specify this coefficient on a
material-by-material basis, which isn
'
t exactly accurate. If you look on the Web,
you
ll find that these numbers are presented in tables that match two materials
together, such as steel on steel or brass on oak or steel on ice. In other words, you
'
ll
likely need to tweak values for your objects until they seem right. A good safety tip is
to make this a data file somewhere that you can tweak at runtime. Trust me, you will
need to do this.
Here are some of the examples of this used in the GameCode4 code base, defined in
Dev/Assets/Config/physics.xml:
'
<PhysicsMaterials>
<PlayDough friction=
0.9
restitution=
0.05
/>
<Normal friction=
0.5
restitution=
0.25
/>
<Bouncy friction=
0.5
restitution=
0.95
/>
<Slippery friction=
0.0
restitution=
0.25
/>
</PhysicsMaterials>
This XML file is eventually read in by the physics engine into this structure:
struct MaterialData
{
float m_restitution;
float m_friction;
MaterialData(float restitution, float friction)
{
m_restitution = restitution;
m_friction = friction;
}
};
Search WWH ::




Custom Search