Skip to content

feat: Non-deterministic debug simulator in UnityTransport [MTT-4592] #2196

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

Merged
merged 3 commits into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ Additional documentation and release notes are available at [Multiplayer Documen

## [Unreleased]

### Changed

- 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)

### Fixed

- Fixed ILPP `TypeLoadException` on WebGL on MacOS Editor and potentially other platforms. (#2199)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ public struct SimulatorParameters
PacketDropRate = 0
};

internal uint DebugSimulatorRandomSeed { get; set; } = 0;
internal uint? DebugSimulatorRandomSeed { get; set; } = null;

private struct PacketLossCache
{
Expand Down Expand Up @@ -1325,7 +1325,7 @@ private void ConfigureSimulator()
packetDelayMs: DebugSimulator.PacketDelayMS,
packetJitterMs: DebugSimulator.PacketJitterMS,
packetDropPercentage: DebugSimulator.PacketDropRate,
randomSeed: DebugSimulatorRandomSeed
randomSeed: DebugSimulatorRandomSeed ?? (uint)System.Diagnostics.Stopwatch.GetTimestamp()
#if UTP_TRANSPORT_2_0_ABOVE
, mode: ApplyMode.AllPackets
#endif
Expand Down