Skip to main content
replaced http://gamedev.stackexchange.com/ with https://gamedev.stackexchange.com/
Source Link

Currently, when I update the entities I calculate the time passed since the last update, and then pass that to their update function. They will in turn pass that duration to all their components.

    currentTime = clock.getTime()
    timePassed = currentTime - lastUpdate

This means that the physics components also gets a variable time step, but it appears this is bad and can lead to inconsistent simulations. Here's some details on this:

> When should I use a fixed or variable time step?When should I use a fixed or variable time step?

The answers suggest that the physics simulation time step should be constant and higher than the rendering time step. But since I can't ensure how well the game will perform, this can be rather difficult to achieve.

One answer suggestsOne answer suggests this:

Use Gaffer's "fix your time step" approach. Update the game in fixed steps as in option 1, but do so multiple times per frame rendered - based on how much time has elapsed - so that the game logic keeps up with real time, while remaining in discrete steps.

This seems like a good approach to me, but I don't really understand how I should be doing it. Instead of doing:

physics.step(timePassed)

I should be doing the following?

while timePassed > 0:
     physics.step(1) # millisecond
     timePassed -= 1

Currently, when I update the entities I calculate the time passed since the last update, and then pass that to their update function. They will in turn pass that duration to all their components.

    currentTime = clock.getTime()
    timePassed = currentTime - lastUpdate

This means that the physics components also gets a variable time step, but it appears this is bad and can lead to inconsistent simulations. Here's some details on this:

> When should I use a fixed or variable time step?

The answers suggest that the physics simulation time step should be constant and higher than the rendering time step. But since I can't ensure how well the game will perform, this can be rather difficult to achieve.

One answer suggests this:

Use Gaffer's "fix your time step" approach. Update the game in fixed steps as in option 1, but do so multiple times per frame rendered - based on how much time has elapsed - so that the game logic keeps up with real time, while remaining in discrete steps.

This seems like a good approach to me, but I don't really understand how I should be doing it. Instead of doing:

physics.step(timePassed)

I should be doing the following?

while timePassed > 0:
     physics.step(1) # millisecond
     timePassed -= 1

Currently, when I update the entities I calculate the time passed since the last update, and then pass that to their update function. They will in turn pass that duration to all their components.

    currentTime = clock.getTime()
    timePassed = currentTime - lastUpdate

This means that the physics components also gets a variable time step, but it appears this is bad and can lead to inconsistent simulations. Here's some details on this:

> When should I use a fixed or variable time step?

The answers suggest that the physics simulation time step should be constant and higher than the rendering time step. But since I can't ensure how well the game will perform, this can be rather difficult to achieve.

One answer suggests this:

Use Gaffer's "fix your time step" approach. Update the game in fixed steps as in option 1, but do so multiple times per frame rendered - based on how much time has elapsed - so that the game logic keeps up with real time, while remaining in discrete steps.

This seems like a good approach to me, but I don't really understand how I should be doing it. Instead of doing:

physics.step(timePassed)

I should be doing the following?

while timePassed > 0:
     physics.step(1) # millisecond
     timePassed -= 1
Tweeted twitter.com/#!/StackGameDev/status/114955944907116544
Source Link
Paul Manta
  • 3.2k
  • 3
  • 31
  • 42

Variable physics step, bad idea?

Currently, when I update the entities I calculate the time passed since the last update, and then pass that to their update function. They will in turn pass that duration to all their components.

    currentTime = clock.getTime()
    timePassed = currentTime - lastUpdate

This means that the physics components also gets a variable time step, but it appears this is bad and can lead to inconsistent simulations. Here's some details on this:

> When should I use a fixed or variable time step?

The answers suggest that the physics simulation time step should be constant and higher than the rendering time step. But since I can't ensure how well the game will perform, this can be rather difficult to achieve.

One answer suggests this:

Use Gaffer's "fix your time step" approach. Update the game in fixed steps as in option 1, but do so multiple times per frame rendered - based on how much time has elapsed - so that the game logic keeps up with real time, while remaining in discrete steps.

This seems like a good approach to me, but I don't really understand how I should be doing it. Instead of doing:

physics.step(timePassed)

I should be doing the following?

while timePassed > 0:
     physics.step(1) # millisecond
     timePassed -= 1