HOWTO fixed vs variable timestep

From ODE
Revision as of 21:31, 6 January 2019 by Russ (talk | contribs) (Created page with "Here is a simple solution for using ODE in an environment with a variable timestep, like a game with an update function that takes the time elapsed since the last call. I just...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Here is a simple solution for using ODE in an environment with a variable timestep, like a game with an update function that takes the time elapsed since the last call. I just used this method in a game I am working on and it works very well, reducing the jitters significantly.

 cache = 0
 timestep = .01

 update(time_elapsed)
 {
   cache += time_elapsed
   while(cache >= timestep)
   {
     ~normal simloop of ode using 'timestep' here ~
     cache -= timestep
   }
 }