Jump to content
  • Advertisement
Sign in to follow this  
LegendofLink

Synchronizing Multiplayer Startup?

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

I'm currently developing a fighting game for the iPhone in my spare time, and I have most of the kinks in the basic engine worked out. Before I proceed with developing the mechanics of the game though, I would like to have a basic networking model functional. The main problem I'm facing in synchronizing the game state between two devices is the fact that the match does not start at the same time on either device.

Currently I am calculating latency between the devices and delaying the start of the match on the "host" device in an attempt to match when the other device receives the start message. Unfortunately, the latency rather wildly fluctuates, meaning that there is no guarantee that the games will start in sync even after compensating for latency. Does anyone here have an idea how I can accomplish this? Any help at all would be appreciated.

Share this post


Link to post
Share on other sites
Advertisement

Currently I am calculating latency between the devices and delaying the start of the match on the "host" device in an attempt to match when the other device receives the start message. Unfortunately, the latency rather wildly fluctuates, meaning that there is no guarantee that the games will start in sync even after compensating for latency. Does anyone here have an idea how I can accomplish this? Any help at all would be appreciated.


You will not be able to perfectly sync the devices. But it doesn't matter -- all that matters is that both devices show the same events happening in the same order. Thus, you should have a notion of "global game time," and make sure that all events are ordered based on this global game time. Each game instance will then try to match global game time to its local time, but exactly what that match is will differ for different clients, based on latencies and whatnot.

Share this post


Link to post
Share on other sites

[quote name='LegendofLink' timestamp='1304091076' post='4804462']
Currently I am calculating latency between the devices and delaying the start of the match on the "host" device in an attempt to match when the other device receives the start message. Unfortunately, the latency rather wildly fluctuates, meaning that there is no guarantee that the games will start in sync even after compensating for latency. Does anyone here have an idea how I can accomplish this? Any help at all would be appreciated.


You will not be able to perfectly sync the devices. But it doesn't matter -- all that matters is that both devices show the same events happening in the same order. Thus, you should have a notion of "global game time," and make sure that all events are ordered based on this global game time. Each game instance will then try to match global game time to its local time, but exactly what that match is will differ for different clients, based on latencies and whatnot.
[/quote]

In a fighting game, it's actually pretty important that things happen at as close to the exact same time as possible. That said, the method you described should work towards that end. This is the method I'm planning for a current venture of my own with similar requirements.

Share this post


Link to post
Share on other sites
Hi! I suggest you to "ping" the clients a few times with a short message, and then use the average time taken to sync after.
You could let the clients be aware of this too, -I'm sure you'll find that this method could give a more qualified impression of the latency.

Share this post


Link to post
Share on other sites

In a fighting game, it's actually pretty important that things happen at as close to the exact same time as possible. That said, the method you described should work towards that end. This is the method I'm planning for a current venture of my own with similar requirements.


I don't quite understand that statement. Of course, all events need to be ordered, and coordinate the same. This has nothing to do with synchronizing real time, and everything to do with using a consistent time stamp for all events.
Or do you simply mean that it's better if latency is lower? I think we all agree :-) Or are you saying that everybody should have the same latency, for fairness? That's what the lockstep simulation model (check the 1,500 archers article) does, by fixing command latency, and not letting anyone with a longer latency join.

Share this post


Link to post
Share on other sites

[quote name='nfries88' timestamp='1304141319' post='4804658']
In a fighting game, it's actually pretty important that things happen at as close to the exact same time as possible. That said, the method you described should work towards that end. This is the method I'm planning for a current venture of my own with similar requirements.


I don't quite understand that statement. Of course, all events need to be ordered, and coordinate the same. This has nothing to do with synchronizing real time, and everything to do with using a consistent time stamp for all events.
Or do you simply mean that it's better if latency is lower? I think we all agree :-) Or are you saying that everybody should have the same latency, for fairness? That's what the lockstep simulation model (check the 1,500 archers article) does, by fixing command latency, and not letting anyone with a longer latency join.
[/quote]

I'm saying that the time at which they happen should be as close as possible, and that it doesn't matter if they're in the same order if they're half a second off or something (in a fighting game, half a second is enough time to get hit at least once). However, as long as your server respects that latency might be different by using a global time, you should be able to make things kosher. Latency is an important factor, and working around latency is the point in using a global time.

Share this post


Link to post
Share on other sites

[quote name='LegendofLink' timestamp='1304091076' post='4804462']
Currently I am calculating latency between the devices and delaying the start of the match on the "host" device in an attempt to match when the other device receives the start message. Unfortunately, the latency rather wildly fluctuates, meaning that there is no guarantee that the games will start in sync even after compensating for latency. Does anyone here have an idea how I can accomplish this? Any help at all would be appreciated.


You will not be able to perfectly sync the devices. But it doesn't matter -- all that matters is that both devices show the same events happening in the same order. Thus, you should have a notion of "global game time," and make sure that all events are ordered based on this global game time. Each game instance will then try to match global game time to its local time, but exactly what that match is will differ for different clients, based on latencies and whatnot.
[/quote]


Yes I agree. You have a very insightful post my friend.

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!