Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Sync local time with server more accurately #3028

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

BenHamrick
Copy link

When syncing the local time from the server to the client we need to use half the RTT time to get the local time in sync with the server. Otherwise the local time drifts relative to how long the RTT time is.

Changelog

  • Changed: Made half the RTT time be used in the Sync function.

Testing and Documentation

  • No tests have been added.
  • Includes unit tests.
  • No documentation changes or additions were necessary as docs already reflect this behavior.

@BenHamrick BenHamrick requested a review from a team as a code owner August 25, 2024 04:46
@unity-cla-assistant
Copy link

unity-cla-assistant commented Aug 25, 2024

CLA assistant check
All committers have signed the CLA.

@NoelStephensUnity NoelStephensUnity added the stat:in consideration Status - Internal feature evaluation ongoing. label Aug 27, 2024
@NoelStephensUnity
Copy link
Collaborator

@BenHamrick
That does indeed look like it makes sense... half RTT vs 1 full RTT for the delta time adjustment.
Running some tests against this, but so far it looks like that would be a welcome contribution.
👍

@BenHamrick
Copy link
Author

BenHamrick commented Aug 27, 2024

@NoelStephensUnity I am really glad to hear that! We are using the tick in our own custom physics engine to do predictive rollback on the server and client. I have been so confused for a long time about why the tick is not in sync between the client and the server. We even started to write our own syncing system that worked around this problem like people are in this thread: https://discussions.unity.com/t/network-messaging-latencies-very-high/912504/2 . I probably spent more than 40 hours trying to work around the issue by dynamically changing the NetworkManager.NetworkTimeSystem.LocalBufferSec

Btw to figure this problem out I used the relay server with 2 instances of unity running on the same machine. Then I was able to use local epoch time to see if each of the ticks are in sync between the server and client. They where not!

@BenHamrick
Copy link
Author

@NoelStephensUnity how long does it take to merge and backport a simple change like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stat:in consideration Status - Internal feature evaluation ongoing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants