Framerate Independence Issue

Post Reply
Apollo
Posts: 17
Joined: Wed Dec 21, 2016 1:15 pm

Framerate Independence Issue

Post 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
ktfh
Posts: 44
Joined: Thu Apr 14, 2016 3:44 pm

Re: Framerate Independence Issue

Post 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);
ghost_pickle
Posts: 6
Joined: Mon Jan 16, 2017 11:38 pm

Re: Framerate Independence Issue

Post 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
User avatar
Typhontaur
Posts: 135
Joined: Fri Nov 04, 2005 2:22 pm

Re: Framerate Independence Issue

Post 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
Apollo
Posts: 17
Joined: Wed Dec 21, 2016 1:15 pm

Re: Framerate Independence Issue

Post 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!
Post Reply