Sign in to follow this  

Fixed-Time step only for physics ?

This topic is 1197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all,

Fixed time step is used for physic update, is it better to do all using fixed time step ?

Is it better to do variable time step and have a fixed time step update function ?

Thanks for the help

Edited by Alundra

Share this post


Link to post
Share on other sites
I prefer using fixed time steps for everything except rendering, rendering is just interpolating between the most recent two time-steps.

the real time can vary a lot, sometimes you can have some multi-gpu system where you can push 4 frames into a queue in no time and then wait for 66ms to push another 4 frames, sometimes some hard disk or antivirus or even some DRM driver can stall your game for 500ms and then you go on with 10ms frames.

and everything beside linear motion behaves differently with just simple lerping, on the other side, complex interpolation is usually also just approximated and yet might take a lot of time while you might not need it with high framerates (so it might result in lower fps without any benefit).

and worst of all, you cannot test all special cases. imagin a monster that guards a path, now some players use a time-freeze tool to stall the cpu for 500ms and next frame he jumped past that guarding monster... or you test your physics puzzle on a nice and fast quadcore and it works, but some player has a dualcore low end cpu with an overpowered gpu and his your puzzle is a game breaker.


it's just a lot of head ache and wasteful to have a dynamic update for anything but rendering, but even for rendering you should try to average the frametime and even balance the frametime, a stable 30fps feels better than 60fps with jittering frames (e.g. due to multi gpu).

Share this post


Link to post
Share on other sites

Fixed-timestep everything is simple, classic, and best. Preferably synced to video refresh.

 

I've learned not to bother with variable timesteps or interpolation. It's a lot of complication for little/no benefit.  If you can't quite keep up with 60 fps, you get stuttering. You can smooth it out by skipping a few renders, but if there's more than~30ms lag, let it freeze (unless it's network multiplayer). If it keeps happening it'll look jumpy, so drop your framerate or turn off some effects; 30 fps is better than 55 fps.

 

If input timing is crucial, you could run several physics updates per render frame, or if possible factor the input event timestamp into your calculations.

Share this post


Link to post
Share on other sites

I agree with Hodgman. Keep in mind that this has nothing to do with if your game is single/multi threaded. This is only a way of saying: "Do a for loop in my game with the fixed step being the index of the array!". If your index is out of bound, you'll explode your array (simulation/logic in this case).

You can increment the index doing: CurrentArrayIndex += FixedTimeStep.

Edited by Irlan R.

Share this post


Link to post
Share on other sites

If you have to ask, and want a rule that just works without having to think too hard, then use a fixed timestep.

 

if you understand the underlying system, can figure out what problems and benefits you might get, then a variable timestep might be better. it will depend on the game and platform. 

 

I use a variable step so that I always have an integer number of physics steps per render update - but that integer is adjusted to keep the physics step itself reasonable. I have no need for determinism, am confident that my simulation is well behaved for the range of timesteps that can occur, and as a result don't need to interpolate between physics frames (which can simplify debug output too). This is for my PicaSim flight simulator.

Share this post


Link to post
Share on other sites

This topic is 1197 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this