What's a good way to synchronize network time and process across all clients?

Godot Version

4.3

Question

Since I’ve now finished some basic networking functions, like movement and jumping, over a dedicated server; I’m now establishing the foundations for advanced networking features needed for a PvP, third-person shooter.

I’m starting with entity interpolation. Which smooths out the movement of other players based on the predicted action of the next network tick.

Here the thing, I currently don’t have any sort of network process implemented yet; and am looking for a solid way to do it.

I’m looking to replace _physics_process with a new _network_physics_process to have the all player physics on the same page for physics. And the same goes for _process.

Does anyone have any solid starting points?

Here is an old Godot 3 tutorial on clock sync. I started with this, but changed directions when Godot 4 introduced the multiplayer nodes.

Clock sync

Series Playlist
https://youtube.com/playlist?list=PLZ-54sd-DMAKU8Neo5KsVmq8KtoDkfi4s&si=y0OCKQLrIUHZThFO

What I’m doing now is leveraging the the _physics_process as my time step. And add a frame count to the MultiplayerSynchronizer state. Although this is still a work in progress, so I’m not sure where I will land on with it.

To answer your question, no not really. You would need to manipulate the mainloop of the engine to introduce a new periodic function.

But it is not impossible. I would look into extending the the mainloop class to see if you can tie in your function call that will go and check every node that may need the networked_physics_process to be called. (Maybe not very efficient, especially in gdscript)

You could setup a group that any node that needs the new function call, to add itself to the group and the system will use process to keep track of time and then periodically call the group function.

1 Like

This is a great series of videos. I’ll also check out the one about interpolation first. Also, since I’m just developing an MVP, I just need the game to work on the most basic level.

Don’t replace _physics_process unless you have a clear reason to do so. In terms of interpolation/smoothing you don’t even need to synchronize time; you just need to know how far ahead/behind a position update is relatively speaking. At some point you might want to synchronize timestamps or get a relationship between server and client timestamps but doing that prematurely could be a mistake.

1 Like

Thanks for the heads up. I’m looking into interpolation at the moment.