Sign in to follow this  

How to handle oject creation while replaying past gamesates

Recommended Posts

simonlourson    140



I'm developing a fast paced networked action game. In my game, the server keeps a circular buffer of past gamestates, so I can replay client input in the past (for client prediction)


My question is, how do i handle object creation in the circular buffer?


For example, let's say the server has received an input from client A, telling it to fire bullets (my bullets are ballistic types, not instantaneous) at frame 10. 3 bullets are created, and I send these objects creation to each of the clients.


When I'll be replaying my circular buffer during the next timestep, those bullets will be re-created, and not necessarily with the same ids, which is a problem, because I don't want to resend the creation of these bullets to each client!


Is my question clear enough ? How can I handle the fact that some actions need to be definitive (object creation), while at the same time replaying my circular buffer of past gamestates according to new user input?

Share this post

Link to post
Share on other sites
hplus0603    11347

You need to deal with the fact that objects aren't existing in the past, and those objects can get un-created if it turns out re-play doesn't re-create them.


One way of doing this is to give each object a "created on step number" value, and if you rewind to step S, delete all objects that were created on step S or later. Assuming networking/inputs are correct, those objects will get re-created again. This can probably be optimized by saving the "uncreated" objects as cached copies to use for re-creating them, assuming they will actually be re-created. Any cached copy that wasn't re-created during its original creation step can be destroyed.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this