Skip to content

Simplify dt handling in space.step() to encourage a stable dt value #282

@viblo

Description

@viblo

Many users that are not experienced with physics engines will believe that the best design is to pass in the frame time (the actual time that passed since the last time step was called) as dt in space.step(dt). However, in Pymunk (and others) its much better if the dt value used is stable, a fixed value. With a stable dt it will be easier for the engine to create a realistic and stable simulation.

However, as of Pymunk 6.x the API of Pymunk does not make this clear, the user should pass in a dt value every time step(dt) is called, and can easy get the impression that it is good if it changes according to actual time passed.

I have two ideas:

  1. Add a default for dt of 1/60.0: def step(self, dt=1/60.0). Minimal changes to the API, should help the user a bit.
  2. Move the dt value to a property on the Space. So you do space = pymunk.Space(dt=1/60), or later `space.dt = 1/60), just like how you deal with gravity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions