Skip to content

breaking: NetworkTime. scaled + unscaled time#4119

Open
miwarnec with Copilot wants to merge 3 commits into
masterfrom
copilot/breaking-networktime-scaled-unscaled-time
Open

breaking: NetworkTime. scaled + unscaled time#4119
miwarnec with Copilot wants to merge 3 commits into
masterfrom
copilot/breaking-networktime-scaled-unscaled-time

Conversation

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

NetworkTime.time previously only synced Time.unscaledTimeAsDouble. Now syncs both scaled and unscaled server time to clients in the same message.

API

// scaled server time (Time.timeAsDouble), respects Time.timeScale
NetworkTime.time

// unscaled server time (Time.unscaledTimeAsDouble), ignores Time.timeScale
NetworkTime.unscaledTime

Changes

  • TimeSnapshotMessage: Added double scaledTime field. Unscaled time continues to come from the batch header.
  • NetworkTime: Added localScaledTime, unscaledTime properties. time now returns scaled synced time.
  • NetworkClient / NetworkConnectionToClient: Parallel snapshot interpolation for scaled time (localTimelineScaled, snapshotsScaled, etc.). Scaled timeline steps with Time.deltaTime; unscaled with Time.unscaledDeltaTime.
  • Internal consumers: NetworkTransform, PredictedRigidbody, InterestManagement, EncryptionTransport switched to NetworkTime.unscaledTime (they depend on unscaled time internally).
  • Tests: Mirror tests for scaled time init, buffer management, dynamic adjustment, and disconnect reset.

Breaking

NetworkTime.time changed from unscaled → scaled. Existing code relying on unscaled behavior should migrate to NetworkTime.unscaledTime.

Copilot AI added 2 commits July 6, 2026 14:11
- NetworkTime.time now returns scaled time (Time.timeAsDouble) synced to clients
- NetworkTime.unscaledTime returns unscaled time (Time.unscaledTimeAsDouble) synced to clients
- Both are synced in the same TimeSnapshotMessage
- Added parallel snapshot interpolation for scaled time
- Updated internal components to use unscaledTime where appropriate
- Added tests for scaled time snapshot interpolation
@miwarnec

miwarnec commented Jul 6, 2026

Copy link
Copy Markdown
Collaborator

@copilot for snapshot interpolation, the network conditions are going to be exactly the same for scaled and unscaled time so reuse the same interpolation for both times. just modify the timesnapshot struct to store both etc

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 42.23%. Comparing base (31163ab) to head (95f6717).

Files with missing lines Patch % Lines
...omponents/PredictedRigidbody/PredictedRigidbody.cs 0.00% 4 Missing ⚠️
...atialHashing/HexSpatialHash2DInterestManagement.cs 0.00% 2 Missing ⚠️
...atialHashing/HexSpatialHash3DInterestManagement.cs 0.00% 2 Missing ⚠️
Assets/Mirror/Core/NetworkTime.cs 33.33% 2 Missing ⚠️
Assets/Mirror/Core/NetworkServer.cs 50.00% 1 Missing ⚠️
...irror/Transports/Encryption/EncryptionTransport.cs 0.00% 1 Missing ⚠️

❌ Your patch check has failed because the patch coverage (52.00%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4119      +/-   ##
==========================================
+ Coverage   42.22%   42.23%   +0.01%     
==========================================
  Files         156      156              
  Lines       15100    15108       +8     
==========================================
+ Hits         6376     6381       +5     
- Misses       8724     8727       +3     
Flag Coverage Δ
unittests 42.23% <52.00%> (+0.01%) ⬆️
unity-6000.5.1f1 42.23% <52.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...ponents/NetworkTransform/NetworkTransformHybrid.cs 0.00% <ø> (ø)
...nents/NetworkTransform/NetworkTransformReliable.cs 0.00% <ø> (ø)
...nts/NetworkTransform/NetworkTransformUnreliable.cs 26.92% <ø> (ø)
Assets/Mirror/Core/Messages.cs 100.00% <ø> (ø)
Assets/Mirror/Core/NetworkClient.cs 93.80% <100.00%> (+<0.01%) ⬆️
...ets/Mirror/Core/NetworkClient_TimeInterpolation.cs 93.61% <100.00%> (-4.12%) ⬇️
Assets/Mirror/Core/NetworkConnectionToClient.cs 100.00% <100.00%> (ø)
.../Mirror/Core/SnapshotInterpolation/TimeSnapshot.cs 100.00% <100.00%> (ø)
Assets/Mirror/Core/NetworkServer.cs 68.47% <50.00%> (ø)
...irror/Transports/Encryption/EncryptionTransport.cs 29.33% <0.00%> (ø)
... and 4 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…caled time

Store both remoteTime (unscaled) and remoteScaledTime (scaled) in the
same TimeSnapshot struct. Use a single interpolation pipeline and derive
scaled time from the same interpolation factor t.

Removes all parallel scaled interpolation (separate buffers, EMAs,
timescales) from NetworkClient and NetworkConnectionToClient.

Copilot AI commented Jul 6, 2026

Copy link
Copy Markdown
Contributor Author

@copilot for snapshot interpolation, the network conditions are going to be exactly the same for scaled and unscaled time so reuse the same interpolation for both times. just modify the timesnapshot s...

Refactored in commit de03bd1 → now uses a single interpolation pipeline for both times. TimeSnapshot stores both remoteTime (unscaled) and remoteScaledTime (scaled). The interpolation factor t from the single pipeline is reused to derive scaled time via Mathd.LerpUnclamped(from.remoteScaledTime, to.remoteScaledTime, t). Removed all parallel buffers, EMAs, and timescales from both NetworkClient and NetworkConnectionToClient.

@miwarnec miwarnec marked this pull request as ready for review July 7, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants