Recommended Posts

I'm working on a side scroller, and am running into problems with physics and rendering.
If I update the physics 60 times per second, and render it after every update, it all runs fine, and works as it should.
If I run one of my other programs in the background to slow the rendering down (while keeping Vsync on), the rendering looks horrible.
Of course if I turn Vsync off, and it runs at ~130 FPS, I get bad visual artifacts.
So basically, if it renders at a different rate than the physics are updated, the rendering doesn't look good at all.
Anyone have a solution for something like this?
Thanks
-Shane

Share this post

Link to post

Share on other sites

Lock the physics update frequency, and then interpolate/extrapolate animation in the renderer. If you can put up with a 1 cycle physics lag, then in each physics update you'd have

currentState = nextState;nextState = physicsStep(currentState);

Which lets you interpolate between currentState and nextState in the rendering. This is how Shellshock did it, IIRC (look at their article on gamasutra). The alternative is to just extrapolate based on previousState and currentState.