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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: