Advertisement

Consistent physics at different framerates

Started by November 05, 2015 04:37 PM
10 comments, last by Irlan Robson 9 years, 3 months ago

This should help you measure correct time values: https://irlans.wordpress.com/2015/01/16/asynchronous-keyboard-input/

Thank you for posting that, I was wondering how this would work with inputs.

There is one more question I have, and that is about what timestep I should use. I was wondering before if the timestep would be equivalent to the best fps my game would show, e.g. 16 = 60fps. I am doing interpolation as well, so how smooth the movement is should be dependent on if I can get a new state to interpolate with every cycle of the loop I think? Or does the interpolation automatically smoothen the movement since my accumulator still gets higher so every frame drawn will still be different?

Obviously if a computer can't reach 60 FPS then each frame more steps are going to be taken and the rendering is going to be slow. So basically for the first statement: no, it varies between computers.

I personally use 33333 us (30 Hz) or 16666 us (60 Hz) for game ticks. The latter is usually preferred to update physics if stability is the main priority. I use that along with the semi-implicit (or sympletic) euler's method whenever possible.

I don't know if I understand your second question. AFAIK linear interpolation as in here smoothes rendering and not game updates (A.K.A ticks). I've never used to interpolate between body dynamics. Sorry!

This topic is closed to new replies.

Advertisement