chipmunk or box2d?

Started by
10 comments, last by Funkymunky 16 years, 3 months ago
Using a fixed timestep for physics means you always run the same number of physics frames per second, thus it'll act the same on all systems. This is better in many ways than changing the timestep based on your (display) frame rate. Variable timesteps don't work with some integration methods (Verlet) and can cause inaccurate/unpredictable results with others if the frame rate drops too low.

The easiest way to implement fixed physics timesteps with variable frame rate is to simply run N timesteps each frame, where N varies depending on how much time has elapsed since the last frame. I tend to use a timer that increments a counter e.g. 100 times a second, so each frame I just check how much the timer has changed and do that many physics updates. I usually limit it to maximum of ten updates per frame to prevent runaway slowdown (too many updates slows down the frame rate, causing even more updates next frame etc).
Advertisement
Ah, I understand. Excellent, I am quite pleased with this performance. Thank you all for your help!

This topic is closed to new replies.

Advertisement