Synchronizing World Events on Server and Client

Options
Hi Boltians,

I am trying to synchronize a particular world event in my game between the server and clients, and I can't seem to get everything exact. When running on my local system the client lags the server by about a half a second.

My code works as such...
1) At a specific time, chosen by the server, the server creates a Bolt Event to send to the client. This Bolt Event tells that client that at the current BoltNetwork.serverFrame + 2000 frames in the future to start a specific world event in the game. My game is about Ants so this specific world event is that rain starts to drop from the sky.
2) Client receives the Event a frame or so later.
3) At this point, both the Server and Client are counting down the frames in their respective FixedUpdate(). The client and server are both waiting until their current BoltNetwork.serverFrame == Original BoltNetwork.serverFrame + 2000.
4) Once that frame is reached both the Server and the Client start the world event (rain drops) at the same time. I have both the Server and Client print the BoltNetwork.serverTime and BoltNetwork.serverFrame at which they start the world event and I have confirmed they are both exactly the same. So, from the debug prints, everything looks correct.

The problem is that I can visuallly tell and hear that the client is about a half a second behind the server.

My guess is that I am misusing BoltNetwork.serverFrame in order to sync up the server and client.

Any ideas on what I am doing wrong? Or if there is a better way to go about my business?

Thanks,
Craig

Comments

  • DirtyHippy
    Options
    The first question would be: is there any reason to attempt perfect sync? If it is just rain, just send an event or use a state property to indicate it is raining. If the client starts a few hundred milliseconds after the server, who cares? It doesn't affect gameplay. Now, in your case I don't know if the raindrops pose hazards to the ants, and in that case it gets a bit trickier if the rain drops have to be synced up exactly to the server.
  • Craig87
    Options
    Yep, in my case the rain drops are large projectiles and if they hit the player they kill the player. I have the projectile code working well using the origin Bolt.serverFrame to calculate where the projectile should be any X frames later. Not using rigid bodies or Unity physics. So I am not worried about that.

    The problem is just that the event starts half a second later on the client and I am worried that the player will get killed by the rain drop hitting them on the server, but the player is able to run away from the rain drop on their client that is a half second late.