Game Development Reference
In-Depth Information
after the update. If the damping is zero, then the velocity will be reduced to nothing:
this would mean that the object couldn't sustain any motion without a force and
would look odd to the player. A value of 1 means that the object keeps all its velocity
(equivalent to no damping). If you don't want the object to look like it is experiencing
drag, then values near but less than 1 are optimal—0.995, for example.
3.2.2
T HE S ECOND L AW
The second law (Newton 2) gives us the mechanism by which forces alter the motion
of an object. A force is something that changes the acceleration of an object (i.e., the
rate of change of velocity). An implication of this law is that we cannot do anything to
an object to directly change its position or velocity; we can only do that indirectly by
applying a force to change the acceleration and wait until the object reaches our target
position or velocity. We'll see later in the topic that physics engines need to abuse this
law to look good, but for now we'll keep it intact.
Because of Newton 2, we will treat the acceleration of the particle different from
velocity and position. Both velocity and position keep track of a quantity from frame
to frame during the game. They change, but not directly, only by the influence of ac-
celerations. Acceleration, by contrast, can be different from one moment to another.
We can simply set the acceleration of an object as we see fit (although we'll use the
force equations in Section 3.2.3), and the behavior of the object will look fine. If we
directly set the velocity or position, the particle will appear to jolt or jump. Because
of this the position and velocity properties will only be altered by the integrator and
should not be manually altered (other than setting up the initial position and velocity
for an object, of course). The acceleration property can be set at any time, and it will
be left alone by the integrator.
3.2.3
T HE F ORCE E QUATIONS
The second part of Newton 2 tells us how force is related to the acceleration. For
the same force, two objects will experience different accelerations depending on their
mass. The formula relating the force to the acceleration is the famous
¨
f
=
ma
=
m
p
[3.1]
Wherewearetryingtofindtheacceleration,wehave
1
m f
p
¨
=
[3.2]
where f is the force and m is the mass.
In a physics engine we typically find the forces applying to each object and then
use equation 3.2 to find the acceleration, which can then be applied to the object by
the integrator. For the engine we are creating in this part of the topic, we can find
Search Nedrilad ::




Custom Search