[Networking] Synchronized time across server and all clients?

Hey guys,

So in order to implement some networking techniques, such as client-side prediction, I need an accurate way of time-stamping messages sent from the server, and comparing them to a synchronized clock on the receiving clients.

Because discussions of this usually relate to much lower-level implementations, such as discussing packet-by-packet, I would have thought that UE4 had had its own methods, such as a way of getting the time, as a client, which is automatically synchronized with the server every x ticks.

Any ideas?


It’s very useful also when you have CAVE setups (that it’s my current problem).

I’m attempting to write my own - you need to resync the time every 5-10 seconds though, and it’s not accurate to the millisecond or anything. But enough for stamping movement info for net play, for example :slight_smile: Have you tried anything?

Currently we have “hacked” our system to hide some of the problems as we would like to avoid to maintain a custom build of UE4 (our project involves multiple companies, it would be problematic otherwise).

We spot UWorld::Tick() method in LevelTick.cpp as a good candidate where timers are updated. I think a proper solution should be to use the server timers as “authoritative” and let the clients smoothly update their internal timers to match the authoritative ones. But problems could arise if side-effects appear (e.g. in the physics simulation). A more deeply knowledge of UE4 networking details should be required for this task.

Hey guys if anyone new is looking for this problem try using the “Get server world time seconds” from the game state.

Thank you very much. It was exactly what I needed.

As far as I can tell, this isn’t precise enough to be able to handle client-side prediction. It’s using the regular game time, not the high-precision timer (FPlatformTimer::Seconds()). Further, it will not account for network lag.