Jump to content
  • Advertisement
Sign in to follow this  
Nairou

Is separate past/present game state always necessary?

This topic is 2125 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

By game state, I just mean data, such as object positions and attributes, active players, etc.

I know for FPS games, having separate past/present (or, more likely, current/next) states is useful, because things happen so fast and you want to allow multiple things to happen at once rather than sequentially. For example, two players shoot each other at the exact same time. If you have only one game state, player 2's shot could get ignored, since it gets processed after player 1's shot, by which time player 2 is marked as dead. If you have separate current/next game states, the shots fired are read from the "current" state but the players are marked as dead in the "next" state, which doesn't go into effect until the next cycle.

However, for other games such as RTS games, things happen at a much slower pace, and I can think of situations where separate game states might be weird. For example, two units are gathering a resource. If you have separate states, and both units happen to arrive at the resource at the same time, they will both get it, since there is no immediate knowledge if the resource being removed. Whereas with a single game state, one of the units would grab it and the other would find it missing and need to look for another.

I always assumed separate game states would be necessary, no matter what, to maintain the integrity of the simulation, but now I'm not so sure if that is true. Thoughts?

Share this post


Link to post
Share on other sites
Advertisement
It's really a design issue more than anything -- double-buffering the state is one way of dealing with it, a careful ordering of update events is another, keeping things decoupled is yet another.

For example, most projectiles in most FPS games today aren't instantaneous (meaning, they travel and are affected by drop, and aren't just a simple ray-test) so they should be entities in their own right, and continue to exist even if the player that fired them has died. That's an example of de-coupling.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!