You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: more accurate local time sync with server time (up-port) (#3212)
* get a more accurate local time by using half the RTT.
* test
Adjusting ClientNetworkTimeSystemTests to account for half RTT adjustment applied in this PR.
* style
Adding a comment about the change
* update
Adding changelog entry
* style
removing white space after comment
---------
Co-authored-by: CTHULHU\Ben <[email protected]>
Copy file name to clipboardExpand all lines: com.unity.netcode.gameobjects/CHANGELOG.md
+1
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
12
12
13
13
### Fixed
14
14
15
+
- Changed the `NetworkTimeSystem.Sync` method to use half RTT to calculate the desired local time offset as opposed to the full RTT. (#3212)
15
16
- Fixed issue where a spawned `NetworkObject` that was registered with a prefab handler and owned by a client would invoke destroy more than once on the host-server side if the client disconnected while the `NetworkObject` was still spawned. (#3200)
// server speedup/slowdowns should not be affected by RTT
45
+
Assert.True(Math.Abs(offsetToTarget)<k_AcceptableRttOffset,$"Expected offset time to be less than {k_AcceptableRttOffset}ms but it was {offsetToTarget}!");
44
46
45
47
// run again, test that we never need to speed up or slow down under stable RTT
// server speedup/slowdowns should not be affected by RTT
59
+
Assert.True(Math.Abs(offsetToTarget)<k_AcceptableRttOffset,$"Expected offset time to be less than {k_AcceptableRttOffset}ms but it was {offsetToTarget}!");
57
60
58
61
// difference between first and second offset should be minimal
Assert.True(expectedSpeedUpTime<k_AcceptableRttOffset,$"Expected local speed up time to be less than {k_AcceptableRttOffset}ms but it was {expectedSpeedUpTime}!");
112
+
// server speedup/slowdowns should not be affected by RTT
113
+
Assert.True(Math.Abs(totalServerSpeedUpTime)<k_AcceptableRttOffset,$"Expected server speed up time to be less than {k_AcceptableRttOffset}ms but it was {expectedServerSpeedUpTime}!");
107
114
108
115
109
-
// run again with RTT ~100ms and see whether we slow down by -0.1f
116
+
// run again with RTT ~100ms and see whether we slow down by -halfRtt
110
117
unscaledLocalTime=timeSystem.LocalTime;
111
118
unscaledServerTime=timeSystem.ServerTime;
112
119
@@ -121,13 +128,13 @@ public void RttCatchupSlowdownTest()
Assert.True(expectedSpeedUpTime<k_AcceptableRttOffset,$"Expected local speed up time to be less than {k_AcceptableRttOffset}ms but it was {expectedSpeedUpTime}!");
136
+
// server speedup/slowdowns should not be affected by RTT
137
+
Assert.True(Math.Abs(totalServerSpeedUpTime)<k_AcceptableRttOffset,$"Expected server speed up time to be less than {k_AcceptableRttOffset}ms but it was {expectedServerSpeedUpTime}!");
0 commit comments