About fixed time step update catch up

Started by
8 comments, last by wintertime 10 years, 4 months ago

For fixed time step update, if the game is running slow, the logic update should update more than once to catch up.

But if the cause is that logic update is slow because heavy AI code and mesh level collision detection, then catching up will make the game slower and slower. In this situation, if I am not going to catch up, is there any side effects?

Thanks.

Advertisement

Well, if your computer isn't fast enough to run the logic as fast as required, you have to decide what to do. I guess you can either allow the game to run slower, you can freeze the game momentarily, hoping it is a transient problem, or you can give up and abort with an error message. But I expect the performance bottlenecks to be in other places (graphics or physics).

If your game needs to run on a network, there is nothing you can really do, as synchronization with other clients is the top priority—you simply can’t allow the game to decrease its logical update speed etc.

If it is a single-player game, you have the option to decrease the speed of the game so that it all appears to slow down for the player, probably the lesser of 2 evils.

This is easily implemented by adding a cap to the number of logical updates that can take place in a single frame, and when the maximum is reached, consider any logical updates you had to drop as a loss and do not try to recover them on the next frame.

To answer your actual question, the side-effect is that your game will eventually become unresponsive and considered dead by the player.

L. Spiro

I restore Nintendo 64 video-game OST’s into HD! https://www.youtube.com/channel/UCCtX_wedtZ5BoyQBXEhnVZw/playlists?view=1&sort=lad&flow=grid

Game is slow -> update more -> game is slower -> update even more -> ...

I've seen this called the spiral of death. It results in your game very quickly trying to do 1000 updates per frame, and running at less than 1fps.

It should only happen if the user's PC doesn't meet your minimum hardware requirements. You need to make sure that your game always runs at a decent frame-rate on decent hardware, without entering this death spiral.
L.Spiro covered the solutions above -- put a limit on the number of updates that can occur per-frame, which makes the game run in slow motion for people with below-capable PC's...

In a multi-player game, either everyone has to slow down to the same speed as the slowest person (strategy games with lock-step networking usually do this), or a client running in slow-motion is simply dropped/kicked from the game.

If its a single player game and its constantly very slow, I think the way out would be to switch down to a fixed number of less logical ticks with comparably bigger steps, when the game estimates it will not catch up. Though that would require the foresight to have the logic programmed for variable timesteps, even if in normal case on fast computer it would always do same fixed timestep.

If its a single player game and its constantly very slow, I think the way out would be to switch down to a fixed number of less logical ticks with comparably bigger steps, when the game estimates it will not catch up. Though that would require the foresight to have the logic programmed for variable timesteps, even if in normal case on fast computer it would always do same fixed timestep.

This approach throws away deterministic simulation; in many game types the slightest variations in numerical values (unavoidable after a single increased timestep update, even with the best computation quality) can lead to large differences in game state later on.

Omae Wa Mou Shindeiru

Thanks for everyone, looks like I will need to tweak the performance of my code. Hope I can make it run faster.

Well, I think if the choice is between not playing/game freezes or slightly less accurate simulation, for someone who wants to play a game its clear what he would like more.

Have to be careful with less accurate simulation, at its most extreme it can lead to things like player tunneling through floors and walls and ending up in an unwinnable state.

Yeah right, if its not easy to make working without huge bugs then it would be better to not waste time for this.

This topic is closed to new replies.

Advertisement