I am developing a game similar to "Street Fighter" and two players can fight each other via Internet.

The networking model is "lockstep" by trying to sync user controller status for each frame.

When a game starts, the basic sequences are:

  1. Random matching
  2. Game Start
  3. Player A sends out a message to B every 30ms, and vice versa.

The question is, in step 2, "Game Start", these two players must start at the same time "physically".

I am thinking to negotiate a timestamp (based on UTC) for two players to start the game right upon it. However, I am suspecting the timestamp might be device dependent. Maybe it's possible for a device to report a timestamp that is 10 seconds or 100 seconds behind the other player.

Therefore, I am wondering what's the best solution for this kind of situation when implementing a networking game like this (no server involved)?


1 Answer 1


Even if there's no host or server, one of the players needs to be in control, be the "host".

Assume there's host A and any number of players B (in your case just 1). A pings B and records the average delay. When the game is about to start, A sends to B that it needs to start within N msec (delay value obtained above) after that message arrives.

Now when the game is running A and B each keep their lock-step timers running (30msec in your case). As the time goes, network lag and timers may fluctuate, so you need to adjust to network delay changes and timers imperfections (yes, some clocks can run at minor but noticeably different rates), so each now and then A sends to B request to adjust number of ticks planned ahead (so there's more or less lag, but no stuttering) and by delaying or catching up time between ticks if needed.

No UTC or any local times involved.

  • \$\begingroup\$ Thanks. I was thinking a bit the same about the method. However, for syncing the ticks during the game, I may need more input. I thought it's fine without syncing during the game because a player will always wait(halt) if remote message is not received for the current execution turn. \$\endgroup\$
    – Joe Huang
    Commented Jan 9, 2015 at 9:23
  • \$\begingroup\$ What if you set lockstep to be 2 ticks ahead (60ms) and then network lag drops to 75ms. Now without adjust each and every step will lag for 15ms. Adjusting the lockstep to be 3 ticks ahead would solve that and let the game run smoothly. \$\endgroup\$
    – Kromster
    Commented Jan 9, 2015 at 9:58
  • \$\begingroup\$ Yes, I am planning to implement this adjustment. But in your answer, I thought there were some other sync I need to implement? \$\endgroup\$
    – Joe Huang
    Commented Jan 9, 2015 at 10:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .