Hi,
First of all: yes, I know, there are a lot of topic discussing subjects like this. I open a new topic because I’ve tested many variants and nothing solved my problem.
I’m developing a 2d racing game (top-down mode) in cocos2d-x and box2d.
The game works perfect in iOS, but not in Android. It has problems related to delays… I see the car stuttering/flickering when it’s moving. I don’t know how to explain it, but it’s NOT smooth game-play. It gets stuck. In Apple Devices, it’s very smooth game-play. The problem is Android.
The only reason it seems to be working on iPhone is because the frame rate is steadier than on Android. On Android it tends to fluctuate quite a bit.
The game works in 60 FPS. In update
function, I’m simulating the physics in this way:
int velocityIterations = 8;
int positionIterations = 3;
world->Step(dt, velocityIterations, positionIterations);
And I think it could be the problem.
I think it’s because of the desynchronisation between frame and physics intervals.
In order to achieve a smooth visualisation I should to interpolate or extrapolate physics space to render space every frame (I think).
I’ve tried, for example, this code (thanks to @R101)
const auto maximumStep = 1 / 120.f;
auto progress = 0.0f;
while (progress < dt)
{
const auto step = std::min((dt - progress), maximumStep);
progress += step;
//stepping b2d world based on incoming delta
world->Step(progress, velocityIterations, positionIterations);
}
But it didn’t help me.
Also I’ve tried many variants and i’ve read in forums, etc, but I can’t achieve the perfect smooth gameplay. Help?