Archive for the ‘indigamedev’ Category

Variable and Fixed Time Steps in Games: Another Option?

In my experience, fixed time steps are predictable and easy to code. The biggest drawback I’ve found with using them is that, when choosing a frame rate, there’s a trade off between supporting less-capable hardware and providing nicely responsive player controls for twitchy games. Variable time steps seem daunting for my high school math skills; pretty much anything more advanced than integrating acceleration into position (s = v * t + 1/2 * a * t^2) means that I’m going to need to start buying math friends drinks to explain things to me.

My current strategy is to use variable time stepping for my player movement (running and jumping) and fixed time stepping for everything else (including enemy running and jumping). This means that I’ve used the above formula in my player update code: jumps are an impulse, but gravity, walking, and idle-drag are all accelerations. I’m clamping my variable time step range to between 30fps and 60fps and am testing my running and jumping mechanics by stepping forward with each of those time steps. By making sure that my jumps are the same height at both 30 and 60 fps, I feel comfortable assuming that wild things won’t happen between those two rates.