Unity Fetch Offset NTP
Fetch and calculate time offset from NTP servers directly within Unity. Useful for synchronizing game logic with network time, detecting client-side time manipulation, or maintaining consistent timing across multiplayer applications. Supports custom NTP server addresses and provides millisecond-precision time difference measurements.
be.elab.unityfetchoffsetntp Install via UPM
Add to Unity Package Manager using this URL
https://www.pkglnk.dev/unityfetchoffsetntp.git README Markdown
Copy this to your project's README.md
## Installation
Add **Unity Fetch Offset NTP** to your Unity project via Package Manager:
1. Open **Window > Package Manager**
2. Click **+** > **Add package from git URL**
3. Enter:
```
https://www.pkglnk.dev/unityfetchoffsetntp.git
```
[](https://www.pkglnk.dev/pkg/unityfetchoffsetntp)Used By (2)
README
2024_07_07_UnityFetchOffsetNTP
Just a tool to fetch the offset from a NTP server in Unity3D
If you need to check with Python:
import ntplib
from time import ctime, time, sleep
def check_ntp_server(server):
client = ntplib.NTPClient()
try:
response = client.request(server, version=3)
ntp_time = response.tx_time
local_time = time()
time_difference = (local_time - ntp_time) * 1000 # Convert to milliseconds
print(f"Server {server} is reachable.")
print(f"NTP Time: {ctime(ntp_time)}")
print(f"Local Time: {ctime(local_time)}")
print(f"Time Difference: {time_difference:.2f} ms")
except Exception as e:
print(f"Failed to reach NTP server {server}. Error: {e}")
if __name__ == "__main__":
ntp_server = '192.168.1.118'
ntp_server = '193.150.14.47'
ntp_server = 'raspberrypi5'
ntp_server = 'time.google.com'
while True:
check_ntp_server(ntp_server)
sleep(1)
No comments yet. Be the first!