Hi!
I just changed my xbox360 project to run at 30Hz.
Now the physics simulation runs half as fast, even though I update the space with a lower dt. (1/30)
The physics engine seems to ignore my dt and always run at 1/60. Everything else runs as it's supposed to.
Maybe I forgot some propery or something?
Physics simulation runs half as fast in 30hz
Re: Physics simulation runs half as fast in 30hz
If you're using 1/30, it does integer division and truncates to 0. When 0 is used, the engine defaults to 1/60 seconds. To avoid this, you can do something like 1/30f so it does floating point division.
Re: Physics simulation runs half as fast in 30hz
I wish it was so simple. 1/30 was just an example.
I use Game.ElapsedGameTime.TotalSeconds
it is 0.03333333f
I use Game.ElapsedGameTime.TotalSeconds
it is 0.03333333f
Re: Physics simulation runs half as fast in 30hz
Oh, sorry, I thought you were talking about setting the timestep settings. The value you pass in to the update method is just used to determine the time since the last frame, it doesn't actually integrate the simulation forward by precisely that amount.
The length of time integrated per space update is actually defined by the timestep simulation settings, specifically:
However, one place where the value you pass into the update method is used is in internal time stepping. If you activate it by doing the following:
and pass in X seconds to the update method, it will do some number of steps of timeStepDuration length until X seconds are simulated.
Keeping the actual per-integration timestep constant throughout the simulation is necessary to ensure stability, which is why it's in a simulation settings variable as opposed to being directly based on the value passed into the update.
The length of time integrated per space update is actually defined by the timestep simulation settings, specifically:
Code: Select all
space.simulationSettings.timeStep.timeStepDuration = 1/30f;
However, one place where the value you pass into the update method is used is in internal time stepping. If you activate it by doing the following:
Code: Select all
space.simulationSettings.timeStep.useInternalTimeStepping = true;
Keeping the actual per-integration timestep constant throughout the simulation is necessary to ensure stability, which is why it's in a simulation settings variable as opposed to being directly based on the value passed into the update.
Re: Physics simulation runs half as fast in 30hz
ah great! Now it works!
thanks!
thanks!