Skip to content

Commit f34ded4

Browse files
feat: Non-deterministic debug simulator in UnityTransport [MTT-4592] (#2196)
* feat: Non-deterministic debug simulator in UnityTransport [MTT-4592] * Add PR number to CHANGELOG entry
1 parent a87bfb0 commit f34ded4

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ Additional documentation and release notes are available at [Multiplayer Documen
99

1010
## [Unreleased]
1111

12+
### Changed
13+
14+
- The debug simulator in `UnityTransport` is now non-deterministic. Its random number generator used to be seeded with a constant value, leading to the same pattern of packet drops, delays, and jitter in every run. (#2196)
15+
1216
### Fixed
1317

1418
- Fixed ILPP `TypeLoadException` on WebGL on MacOS Editor and potentially other platforms. (#2199)

com.unity.netcode.gameobjects/Runtime/Transports/UTP/UnityTransport.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ public struct SimulatorParameters
337337
PacketDropRate = 0
338338
};
339339

340-
internal uint DebugSimulatorRandomSeed { get; set; } = 0;
340+
internal uint? DebugSimulatorRandomSeed { get; set; } = null;
341341

342342
private struct PacketLossCache
343343
{
@@ -1325,7 +1325,7 @@ private void ConfigureSimulator()
13251325
packetDelayMs: DebugSimulator.PacketDelayMS,
13261326
packetJitterMs: DebugSimulator.PacketJitterMS,
13271327
packetDropPercentage: DebugSimulator.PacketDropRate,
1328-
randomSeed: DebugSimulatorRandomSeed
1328+
randomSeed: DebugSimulatorRandomSeed ?? (uint)System.Diagnostics.Stopwatch.GetTimestamp()
13291329
#if UTP_TRANSPORT_2_0_ABOVE
13301330
, mode: ApplyMode.AllPackets
13311331
#endif

0 commit comments

Comments
 (0)