Ventures of an indie game developer

Server sync

Struggling with getting app work done, but I almost always end up fixing grisly bugs in the engine. The system is becoming so complex now that it's hard to touch central parts without breaking stuff. My last fixes include better server synchronization. What you see here is two clients (split-screen) where the one on the left shows the physical boundaries of where the server thinks stuff is.

I always run server/client*, even when running only on localhost, and there's always approx. 2 ms lag between a client and the server (server tells client to stay lag+jitter+1 frame ahead so that packets arrive nicely in time to resolve physics). There are three bugs at play here.

  1. A packet loss (due to client packet arriving to late due to overdue timeslice processing) causes a lost movement when the excavator pushes down and "pulls in" the hovercraft beneath it, so when the server informs the others on what has happened, the hovercraft is moved out again.

  2. Due to the small lag, there is some penetration on the remote ends when the excavator tries to hold on to the hovercraft. The penetration exerts a strong force which cause the hovercraft to spin out of control.

  3. As you see in the end, when I rotate the camera somewhat, there is a jerky movement as the excavator rolls. It is caused by "time compression" as the game tries to run at 30.5 Hz and the video recorder at just below 30. Thus the game sometimes needs to take multiple frames in a single step (stretching the frames in game-time is not a good idea since that breaks what little prediction I can muster), and the client and server steps don't coincide.

I won't fix these tacky bugs, but #2 is already solved for non-player objects, which is the important part. Perhaps a lot of players wouldn't have liked being held down by the excavator anyway. :)

* I'll talk more on why this is eating up all my time in some other post.

About the author

Mitt foto
Gothenburg, Sweden