Hi community!
Little help needed.
I have a problem with stuttering, manly because I’m using fixed time step or a least trying :)!
I think that the problem for the stuttering is because I’m missing frames when inside the while cycle, how should I fixed the code so that when I render my assets they will keep up and do not “jump” movement steps?
Wheres the little peace of code I’m using :
private float fixedTimestepAccumulator = 0f;
private final float MAX_ACCUMULATED_TIME = 1.0f;
private final float TIMESTEP = 1/60f;
@Override
public void render(float deltaTime) {
Gdx.gl.glClearColor(172f / 255f, 229f / 254f, 254f / 255f, 1f);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
levelController.handleInputGame(deltaTime);
fixedTimestepAccumulator += deltaTime;
if (fixedTimestepAccumulator > MAX_ACCUMULATED_TIME)
fixedTimestepAccumulator = MAX_ACCUMULATED_TIME;
while (fixedTimestepAccumulator >= TIMESTEP) {
levelController.update(deltaTime);
fixedTimestepAccumulator -= TIMESTEP;
}
levelRenderer.render();
fpsLogger.log();
}
Thank you all!