Page 1 of 1

Framerate Independence Issue

Posted: Fri Feb 03, 2017 3:20 pm
by Apollo
Hi,

We are trying to make our game framerate independent, but are currently having issues with it. We tried reading previous threads on the subject but haven't managed to solve it. We've tried using a fixed timestep as well as a variable timestep, with neither working.

We're currently testing on two PCs with different hardware, comparing how the two character's speeds move. One person gets ~60 FPS, and the other gets around ~110. The character's move at different speeds when both a fixed and variable timestep are used. The two alternative calls to stepSimulation tried are shown below:

Code: Select all

m_world->stepSimulation(1.0f / 60.0f, 10);
m_world->stepSimulation(m_deltaTime, 10);
Given that the fixed timestep specified on the wiki page is 1/60, we have also tried reducing the number of maxSubSteps, once again with no result.

In addition, are we also supposed to multiply the movement speed by deltatime?

Thanks for the help

Re: Framerate Independence Issue

Posted: Tue Feb 07, 2017 8:12 pm
by ktfh
Something like this should work for frame rate independence.

Code: Select all

btClock physicsTimer;
while(true) {
    float m_deltaTime = physicsTimer.getTimeSeconds();
    physicsTimer.reset();
    m_world->stepSimulation(m_deltaTime, 10, 1.f/60.f );
    doSomeRendering();
}
All your movement and forces type logic should be executed from inside a pre-tick callback

Code: Select all

m_world->setInternalTickCallback(myMovementCodeOrWhatever, 0, true);

Re: Framerate Independence Issue

Posted: Wed Feb 08, 2017 4:41 pm
by ghost_pickle
This might provide a good place to start. Its got a good amount of info on getting your applicaiton to be framerate independent (something Skyrim can't boast about!) http://www.bulletphysics.org/mediawiki- ... _Game_Loop

Re: Framerate Independence Issue

Posted: Wed Feb 08, 2017 9:16 pm
by Typhontaur
I use this:
For me it works well ...
maybe can help...

Code: Select all

btClock realClock;
...
...
var x = realClock.getTimeMicroseconds();
realClock.reset();
physicsWorld->stepSimulation(x / (1000000.0f / 2), 4, 1.0f / 60.0f);
...
...
doSomeRendering();
edit*: or ... http://bulletphysics.org/Bullet/phpBB3/ ... eep#p37618

Re: Framerate Independence Issue

Posted: Mon Feb 13, 2017 12:18 pm
by Apollo
ghost_pickle wrote:This might provide a good place to start. Its got a good amount of info on getting your applicaiton to be framerate independent (something Skyrim can't boast about!) http://www.bulletphysics.org/mediawiki- ... _Game_Loop
This worked really well, thank you to everyone for the suggestions!