How to handle oject creation while replaying past gamesates

Started by
0 comments, last by hplus0603 10 years, 10 months ago

Hi.

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?

Advertisement

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.

enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement