Game Development Reference
In-Depth Information
function ( v ( t )) and the derivative of the velocity function is the acceleration func-
tion. Here it is in symbolic form:
But this formulation is not terribly valuable for a game. In a game, we want to be
able to apply a force to an object and from that force determine the acceleration
over time. Once we have the acceleration, we then want to determine the velocity
over time. Finally, with the velocity in hand, we can then determine the position of
the object. All of these are need to be applied over the current time step.
So in other words, what we need is the opposite of the derivative, which you might
recall is the integral. But it's not just any type of integration we're interested in.
You are likely most familiar with symbolic integration, which looks something
like this:
But in a game, symbolic integration is not going to be very useful, because it's not
like we are going to have a symbolic equation to integrate in the first place. Rath-
er, on an arbitrary frame we want to apply the acceleration over the time step to
get the velocity and the position. This means using numeric integration , which
is an approximation of the symbolic integral applied over a specific time step. If
you ever were required to calculate the area under a curve using the midpoint or
trapezoidal rule, you calculated a numeric integral. This section covers a few of
the most common types of numeric integration used in games.
Issues with Variable Time Steps
Before we cover any of the numeric integration methods, it's important to discuss
one big gotcha for any physics-based movement. Once you are using numeric in-
tegration, you more or less cannot use variable time steps. That's because the ac-
curacy ofnumeric integration is wholly dependent onthe size ofthe time step. The
smaller the time step, the more accurate the approximation.
This means that if the time step changes from frame to frame, the accuracy of the
approximation would also change from frame to frame. If the accuracy changes,
the behavior will also change in very noticeable ways. Imagine you are playing a
Search WWH ::




Custom Search