In my game the main character is a structure made up from spheres and cubes.
Player roll this structure using mouse.
In "move" function of this structure, I apply desired angular speed - it moves as I wish, as long as framerate > 60fps.
I used to call simulation step in this way :
Code: Select all
updateMainCharacterMove(_deltaTime);
dynamicsWorld->stepSimulation(_deltaTime, 10);
I assume, that when the framerate is lower then fixedTimeStep, a couple of substeps is calculated, and the angular speed of my rolling structure is not refreshed beetween those substeps.
My workaround (pseudocode):
Code: Select all
// fixedTimeStep = 60Hz
int maxPhysicsSubsteps = deltaTime / fixedTimeStep; // and clamp to [1, 10] , assume no one will play it when fps < 6
float subDeltaTime = deltaTime / maxPhysicsSubsteps;
for (int i = 0; i< maxPhysicsSubsteps; ++i)
{
updateMainCharacterMove(_subDeltaTime);
dynamicsWorld->stepSimulation(_subDeltaTime, 1); // 1 - fixed - do not allow substeps
}
Thanks
Dor