This project has moved and is read-only. For the latest updates, please go here.

F3 - Fixed/Variable timestep

Apr 19, 2010 at 6:45 AM
Edited Apr 19, 2010 at 7:29 AM

Could you please explain the good/bads of using a fixed or variable timestep in Farseer 3?

Also, mat said this: "Switched back to Fixed time step until all demos can be updated to use variable time step." - What changes do you have to make to use a variable timestep?

And will using a variable/fixed timestep affect ApplyForce/ApplyImpulse ?


Apr 19, 2010 at 10:12 PM
Edited Apr 19, 2010 at 10:12 PM
Some of the demos use an accumulation of the frame times to decide what action to take. Also joints are much stiffer and I need to add a time-based approach to solving them. ApplyForce/ApplyImpulse will be fine if you modulate your force amount by the time step amount. This is how it should be done in the first place. Here is how I use a variable time step: // variable time step but never less then 30 Hz PhysicsSimulator.Step(Math.Min((float) gameTime.ElapsedGameTime.TotalMilliseconds * 0.001f, (1f / 30f)), 5, 3); This ensures the engine never uses a time step less then 30 Hz. By changing 0.0001f to higher and lower values you can scale time. This can be used to create slow motion and faster motion effects. I hope this helps you out.
Aug 2, 2010 at 9:47 AM
Does anyone have any input to add to this? I'm pretty sure I want to set a fixed timestep, but I just wanted to know what implications that will have. I've been thinking about slow-mo, and I'm sure I can add it in, but I also have noticed my game run differently on two different PC's. I'm pretty sure fixing the timestep will help fix this, but I want to know what the implications are. Thanks.
Aug 2, 2010 at 10:00 AM

A fixed-timestep runs best, it is the variable-timestep that causes problems! :)

 I found a nice article that explained it a while ago, but I can't find it now. You could probable search for "fixed vs variable timestep" if you wanted to find out more.

So you should be fine!

Aug 3, 2010 at 9:25 AM