Skip to content

Commit

Permalink
test: fixing tests to use to use
Browse files Browse the repository at this point in the history
just using Time.time sometimes causes rounding errors where it will not sync right away. Using timeAsDouble as the internal code does solves this
  • Loading branch information
James-Frowen committed Apr 28, 2024
1 parent 3e9e2a3 commit 70abf06
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ protected static void SetDirection(NetworkBehaviour behaviour, SyncFrom from, Sy

behaviour.SyncSettings.From = from;
behaviour.SyncSettings.To = to;
behaviour._nextSyncTime = Time.time;
behaviour._nextSyncTime = Time.timeAsDouble;
behaviour.UpdateSyncObjectShouldSync();
}
protected void SetDirection(SyncFrom from, SyncTo to)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/Runtime/Syncing/SyncDirectionTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected static void SetDirection(NetworkBehaviour behaviour, SyncFrom from, Sy

behaviour.SyncSettings.From = from;
behaviour.SyncSettings.To = to;
behaviour._nextSyncTime = Time.time;
behaviour._nextSyncTime = Time.timeAsDouble;
behaviour.SyncSettings.Timing = SyncTiming.NoInterval;
behaviour.UpdateSyncObjectShouldSync();
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Tests/Runtime/Syncing/SyncVarVirtualTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private void SyncValuesWithClient()
observersWriter.Reset();

// make sure it is time to sync
serverComponent._nextSyncTime = Time.time;
serverComponent._nextSyncTime = Time.timeAsDouble;
serverIdentity.OnSerializeAll(true, ownerWriter, observersWriter);

// apply all the data from the server object
Expand Down

0 comments on commit 70abf06

Please sign in to comment.