Getting past the physics-timestep barrier

A serious problem that any racing game has to deal with is the battle between laptime-accuracy and performance.

On one hand you can’t do too many physics calculations per second because it kills the frame-rate, but on the other hand you want to do as many as possible to be able to measure lap-times in as small timesteps as possible. (Set the physics to be calucalted 20x/sec and your highscores will only be measured in 0.05 second steps. Now have 1000 people play and 50 of them will share the top spot. Not good… – Set the timestep to 100x/sec and you’ll have a lot more accuracy, but none of the 1000 people will enjoy playing at 5 fps.)

But there’s a clever way around this:
Record the position of the vehicle at each physics calculation and once it crosses the finishing line, use the distance between the last and current points together with the position of the finishing line to calculate when exactly the vehicle must have crossed the line during the last timestep.

Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>