HOWTO fixed vs variable timestep

From ODE Wiki
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
    }
  }