RevenantX / LiteNetLib

Lite reliable UDP library for Mono and .NET
https://revenantx.github.io/LiteNetLib/index.html
MIT License
3.08k stars 497 forks source link

Client Server time synchronizing #498

Closed nongvantinh closed 1 year ago

nongvantinh commented 2 years ago

I'm about to create a fast-paced action game, At the start of a match, client and server sync time and set the match time to 00:00.

Can I use NetPeer.RemoteUtcTime to sync time between server and client to the start of 00:00?

Or do I have to use NtpPacket to do that?

Library version: 0.9.5.2 Framework: [.NET 6, Godot]

OS: [Linux, Windows, Android, iOS]

RevenantX commented 2 years ago

I'm about to create a fast-paced action game, At the start of a match, client and server sync time and set the match time to 00:00.

Can I use NetPeer.RemoteUtcTime to sync time between server and client to the start of 00:00?

Or do I have to use NtpPacket to do that?

Library version: 0.9.5.2 Framework: [.NET 6, Godot]

OS: [Linux, Windows, Android, iOS]

most fast paced games uses fixed tick rate for game logic and tick-time calculation (like 30 TicksPerSecond or 60). So if your game logic is 30 ticks per second - then you can sync time based on tick number on server and local tick number on client.