Jump to content
  • Advertisement
Sign in to follow this  
RedOni

About fixed time step update catch up

This topic is 2160 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Edited by Hodgman

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!