Game Development Reference
In-Depth Information
In other words, the force is converted into an acceleration: the acceleration of the end
of the spring at that instant of time . This acceleration is then applied to the object for
the whole time interval . This would be accurate if the object didn't moveā€”that is, if
the spring were held at a constant extension over the whole time period.
In the real world, as soon the spring has moved a bit, a tiny fraction of the time
interval later, the force will have decreased slightly. So applying the same force for the
whole time interval means we have applied too much force. In figure 6.4 we see that
this doesn't matter very much. Even though the force is too great, the end doesn't
move far before the next time frame, and then a lower force is applied for the next
time frame, and so on. The overall effect is that the spring behaves normally, but it is
slightly stiffer than the spring constant we specified.
Figure 6.5 shows the same problem but with a much stiffer spring. Now the force
in the first frame is enough to carry the end of the spring past the rest length and to
compress the spring. In reality the movement of the spring wouldn't do this: it would
begin to move inward, having had a huge instantaneous force applied, but this force
would drop rapidly as the end moved in.
The figure shows the spring has compressed more than it was extended originally.
In the next time frame it moves in the opposite direction but has an even greater force
applied, so it overshoots and is extended even farther. In each time frame the spring
will oscillate with ever growing forces, until the end of the spring ends up at infinity.
Clearlythisisnotaccurate.
The longer the time frame we use the more likely this is to happen. If your game
uses springs and variable frame-rates, you need to take care that your spring constants
aren't too large when used on a very slow machine. If a player switches all the graphics
options on, and slows her machine down to ten frames per second (or slower), you
don't want all your physics to explode!
F IGURE 6.5
A stiff spring over time.
Search Nedrilad ::




Custom Search