Skip to content

Commit a6b64cf

Browse files
author
Unity Technologies
committed
## [1.6.1] - 2025-05-28 ### Added * Two new entity command buffer systems that run at the beginning and end of the `PredictedSimulationSystemGroup` respectively: `BeginPredictedSimulationCommandBufferSystem` and `EndPredictedSimulationCommandBufferSystem`. * A new internal `PredictedSpawningSystemGroup`, running after the `EndPredictedSimulationCommandBufferSystem`, created to guarantee that when a new snapshot is received from server, all new ghosts are spawned and ready to receive new data. * New documentation regarding the NetworkDriverStore architecture, setup and how to use it in conjunction with Unity.Relay. * Experimental host migration feature added, enabled with the ENABLE_HOST_MIGRATION define but otherwise hidden. * With ENABLE_HOST_MIGRATION defined, when a client reconnects to a server after disconnecting the connection entity on both sides will receive a `NetworkStreamIsReconnected` component. An internal unique ID is added to connections to track this behaviour. * The ability to define a smaller `GhostSystemConstants.SnapshotHistorySize` value via compiler define `NETCODE_SNAPSHOT_HISTORY_SIZE_6` or `NETCODE_SNAPSHOT_HISTORY_SIZE_16`. These values are well suited for larger scale use-cases where server memory is constrained, and snapshot sends of individual ghosts are relatively infrequent. * Support for combining Ghost Relevancy with Ghost Importance Scaling via new `PrioChunks.isRelevant` field, [enabling a fast-path for relevancy calculations](https://docs.unity3d.com/Packages/com.unity.netcode@latest?subfolder=/manual/optimizations.html#relevancy-fast-path-via-importance-scaling). * Analytics to netcode tools to better understand their usage. ### Changed * **Behaviour Breaking Change:** Predicted spawned ghosts for partial ticks skip restoring the state from the backup (and instead continue prediction from their spawn state) when the last backup state tick is identical to the spawn tick, as no data has changed. * **Behaviour Breaking Change:** Reduced the complexity (and performance overhead) of the `GhostCount.GhostCountOnServer` calculations internally. Note that this value is (and always has been) an approximation. * IsReconnected split into NetworkStreamIsReconnected for reconnected connections and IsMigrated for re-spawned ghosts (Host Migration). * Moved host migration related types into a `Unity.Netcode.HostMigration` namespace, renamed the `HostMigration` class to `HostMigrationUtility` so it works in the new namespace. * Prespawn ghost IDs will now be preserved between host migrations * Client connection `NetworkIDs` are now preserved between host migrations. ### Fixed * **Behaviour Breaking Change:** Incorrect state serialized inside the `SnapshotDataBuffer` for predicted spawned ghost on the client when spawned inside the prediction loop. The `PredictedGhostSpawnSystem` is now updated also as part of the prediction loop (inside the `PredictedSpawningSystemGroup`) to ensure that any predicted spawned ghosts on the client are correctly initialized at the tick they are spawned, and not with partial tick state. * Issue where predicted spawned ghosts re-simulated from the wrong tick when configured to rollback to their `spawnTick` and are spawned inside the prediction loop. They are now restored using the corrected full tick state, rather than the erroneous partial tick state. * Enable creating and initializing server drivers when using WebGL to enable self-hosting cases using relay. Many methods were under conditional compilation flags and removed from the WebGL build and not usable outside the editor. * All the unmanaged systems present in the FixedStepSimulationSystemGroup that have a direct or indirect update dependency to the PhysicsSystemGroup are now correctly moved to the PredictedFixedStepSimulationSystemGroup. This is a **Behaviour Change** in respect the previous versions, where all the unmanaged systems continued to stay inside the fixed update group, regardless of the dependency of update order. * An issue with Mutiplayer PlayModeTool window, throwing exceptions when docked after a domain reload. The issue was due to because of an access to `EditorPrefs` and `Application.productName` while restoring the window state. * Issue where, during host migration, ghosts could be migrated with a 0 id and type. Causing various issues when instantiated on the new host. * Crash which could happen after host migrations when the server is deploying the host migration data. * Issue with prespawn prefab entity list initialization after a host migration, the ordering of the prespawn ghosts could be shifted by one because of the internal `PrespawnSceneList` entity prefab creation. This would result in *invalid ghost type X (expected X+1)* off by one style errors. * The prediction loop will no longer rollback too many times when one ghost is switched from predicted to interpolated, and later switched back to predicted, when that ghost is the only predicted ghost. * If you update multiple packages, create a new section with a new header for the other package. * The client packet dump was not being written to the `EnablePacketLogging.NetDebugPacketCache` field, thus were not usable by users and other netcode call-sites (like the `NetworkStreamReceiveSystem`). * `SnapshotHistorySize` values below 32 uncovered an issue where a ghost chunk being written would write over its snapshot history entries for currently-in-flight snapshots, leading to a cycle of never being able to fetch a valid baseline, in perpetuity. The fix for this requires us to stall the send of this ghost chunk if the in-flight queue is full, until the in-flight snapshots are assumed to have either arrived or been lost/dropped. * Buffer serialization errors caused by incorrect pointer stepping when ghost fields are not present (i.e. surrounding `GhostComponentSerializer.State.HasGhostFields`). * Buffer serialization errors caused by missing change mask invalidation when `SendToOwnerType` or `GhostSendType` conditionally prevented sending of the buffer. * Readded `UsePreSerialization` to the `GhostAuthoringComponent` inspector that was accidentally removed. ### Obsolete * Prefer `BatchScaleImportanceDelegate` to `ScaleImportanceFunction` as the latter significantly reduces the total number of function pointer calls.
1 parent df9f911 commit a6b64cf

File tree

148 files changed

+6803
-2331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

148 files changed

+6803
-2331
lines changed

.buginfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
system: jira
2+
server: jira.unity3d.com
3+
project: N4EBUG
4+
issuetype: Bug

.signature

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"timestamp":1746690456,"signature":"bCmoScfUziQEIVPEEIAWoaNL/hjF9HCIdrCY5071qHEiD7upspLf8d3LMsi3LelSuIlWXf82eXsJk8QOWwd6+ldlvNGeTpVGM31sGbhy5zyGGcltSgT4WXk0aYSwKQERwVrB8jckyuByoptTX5JgfweoRvykWVeZWH/Dts67qUhBjSIku3zE3OLjKAucZAQ37nBlIfkk2j9ZWehGzXHmYABX2XPnext0d6/Q4gO5puYKwGPC8oSl/ZXNOGfYok5e3FC0LcFQ0LFju6xSVdfInxX34AHPblQl/2w3PYkmz8dsNn7SlDrg0qfkXznSimJVXq1Vhzl3ZF6GgA+2qO7mtfA8sNfPhKhqfuzArz1Cm8mxJyYD3FhhOhHyEwiKYT8gYLiuZi/o1t7lk9Fja10igqPOv0WwaD0KDqry06tEH4iB+tmr3ahdHasVzGuwoPSBQjLSWaX8cufAJh+B5XiS51lbJ4tJd4FlCfyhDVc2KLF/YfTJJlIvg8Y4YF0ClydK","publicKey":"LS0tLS1CRUdJTiBQVUJMSUMgS0VZLS0tLS0KTUlJQm9qQU5C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S1FTkQgUFVCTElDIEtFWS0tLS0tCg"}

CHANGELOG.md

Lines changed: 32 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,51 @@
11
---
22
uid: changelog
33
---
4-
## [1.5.1] - 2025-05-06
4+
5+
## [1.6.1] - 2025-05-28
56

67
### Added
78

9+
* Two new entity command buffer systems that run at the beginning and end of the `PredictedSimulationSystemGroup` respectively: `BeginPredictedSimulationCommandBufferSystem` and `EndPredictedSimulationCommandBufferSystem`.
10+
* A new internal `PredictedSpawningSystemGroup`, running after the `EndPredictedSimulationCommandBufferSystem`, created to guarantee that when a new snapshot is received from server, all new ghosts are spawned and ready to receive new data.
11+
* New documentation regarding the NetworkDriverStore architecture, setup and how to use it in conjunction with Unity.Relay.
812
* Experimental host migration feature added, enabled with the ENABLE_HOST_MIGRATION define but otherwise hidden.
913
* With ENABLE_HOST_MIGRATION defined, when a client reconnects to a server after disconnecting the connection entity on both sides will receive a `NetworkStreamIsReconnected` component. An internal unique ID is added to connections to track this behaviour.
14+
* The ability to define a smaller `GhostSystemConstants.SnapshotHistorySize` value via compiler define `NETCODE_SNAPSHOT_HISTORY_SIZE_6` or `NETCODE_SNAPSHOT_HISTORY_SIZE_16`. These values are well suited for larger scale use-cases where server memory is constrained, and snapshot sends of individual ghosts are relatively infrequent.
15+
* Support for combining Ghost Relevancy with Ghost Importance Scaling via new `PrioChunks.isRelevant` field, [enabling a fast-path for relevancy calculations](https://docs.unity3d.com/Packages/com.unity.netcode@latest?subfolder=/manual/optimizations.html#relevancy-fast-path-via-importance-scaling).
16+
* Analytics to netcode tools to better understand their usage.
1017

1118
### Changed
1219

20+
* **Behaviour Breaking Change:** Predicted spawned ghosts for partial ticks skip restoring the state from the backup (and instead continue prediction from their spawn state) when the last backup state tick is identical to the spawn tick, as no data has changed.
21+
* **Behaviour Breaking Change:** Reduced the complexity (and performance overhead) of the `GhostCount.GhostCountOnServer` calculations internally. Note that this value is (and always has been) an approximation.
1322
* IsReconnected split into NetworkStreamIsReconnected for reconnected connections and IsMigrated for re-spawned ghosts (Host Migration).
23+
* Moved host migration related types into a `Unity.Netcode.HostMigration` namespace, renamed the `HostMigration` class to `HostMigrationUtility` so it works in the new namespace.
24+
* Prespawn ghost IDs will now be preserved between host migrations
25+
* Client connection `NetworkIDs` are now preserved between host migrations.
1426

1527
### Fixed
1628

29+
* **Behaviour Breaking Change:** Incorrect state serialized inside the `SnapshotDataBuffer` for predicted spawned ghost on the client when spawned inside the prediction loop. The `PredictedGhostSpawnSystem` is now updated also as part of the prediction loop (inside the `PredictedSpawningSystemGroup`) to ensure that any predicted spawned ghosts on the client are correctly initialized at the tick they are spawned, and not with partial tick state.
30+
* Issue where predicted spawned ghosts re-simulated from the wrong tick when configured to rollback to their `spawnTick` and are spawned inside the prediction loop. They are now restored using the corrected full tick state, rather than the erroneous partial tick state.
31+
* Enable creating and initializing server drivers when using WebGL to enable self-hosting cases using relay. Many methods were under conditional compilation flags and removed from the WebGL build and not usable outside the editor.
32+
* All the unmanaged systems present in the FixedStepSimulationSystemGroup that have a direct or indirect update dependency to the PhysicsSystemGroup are now correctly moved to the PredictedFixedStepSimulationSystemGroup. This is a **Behaviour Change** in respect the previous versions, where all the unmanaged systems continued to stay inside the fixed update group, regardless of the dependency of update order.
1733
* An issue with Mutiplayer PlayModeTool window, throwing exceptions when docked after a domain reload. The issue was due to because of an access to `EditorPrefs` and `Application.productName` while restoring the window state.
1834
* Issue where, during host migration, ghosts could be migrated with a 0 id and type. Causing various issues when instantiated on the new host.
1935
* Crash which could happen after host migrations when the server is deploying the host migration data.
2036
* Issue with prespawn prefab entity list initialization after a host migration, the ordering of the prespawn ghosts could be shifted by one because of the internal `PrespawnSceneList` entity prefab creation. This would result in *invalid ghost type X (expected X+1)* off by one style errors.
37+
* The prediction loop will no longer rollback too many times when one ghost is switched from predicted to interpolated, and later switched back to predicted, when that ghost is the only predicted ghost.
38+
* If you update multiple packages, create a new section with a new header for the other package.
39+
* The client packet dump was not being written to the `EnablePacketLogging.NetDebugPacketCache` field, thus were not usable by users and other netcode call-sites (like the `NetworkStreamReceiveSystem`).
40+
* `SnapshotHistorySize` values below 32 uncovered an issue where a ghost chunk being written would write over its snapshot history entries for currently-in-flight snapshots, leading to a cycle of never being able to fetch a valid baseline, in perpetuity. The fix for this requires us to stall the send of this ghost chunk if the in-flight queue is full, until the in-flight snapshots are assumed to have either arrived or been lost/dropped.
41+
* Buffer serialization errors caused by incorrect pointer stepping when ghost fields are not present (i.e. surrounding `GhostComponentSerializer.State.HasGhostFields`).
42+
* Buffer serialization errors caused by missing change mask invalidation when `SendToOwnerType` or `GhostSendType` conditionally prevented sending of the buffer.
43+
* Readded `UsePreSerialization` to the `GhostAuthoringComponent` inspector that was accidentally removed.
44+
45+
### Obsolete
46+
47+
* Prefer `BatchScaleImportanceDelegate` to `ScaleImportanceFunction` as the latter significantly reduces the total number of function pointer calls.
48+
2149

2250

2351
## [1.5.0] - 2025-04-22
@@ -74,7 +102,7 @@ uid: changelog
74102
* Inconsistencies in documentation around RollbackPredictionOnStructuralChanges have been fixed and sorted out a couple of typos.
75103
* Issue with prespawned ghosts not updating anymore after the client disconnects and reconnects to a server.
76104
* Issue where Ghost Importance Scaling would throw if the `GhostDistancePartitionShared` (or user-code equivalent `GhostImportancePerChunkDataType`) was only added to a subset of ghost instances.
77-
* The `GhostDistancePartitioningSystem` is now significantly faster in cases where the `GhostDistancePartitionShared` is able to successfully exclude unchanged `LocalTransform` chunks (via change filtering). `AddSharedDistancePartitionJob` is now `.ScheduleParallel` (from `.Schedule`), as there is no reason not to queue ECB operations in parallel.
105+
* The `GhostDistancePartitioningSystem` is now significantly faster in cases where the `GhostDistancePartitionShared` is able to successfully exclude unchanged `LocalTransform` chunks (via change filtering).
78106
* an issue in MultiPhysics sample, causing particle emitter not spawning particles in the client-only physics world.
79107
* an issues with GhostPresentationGameObjectSystem throwing ObjectDisposedExceptions when entity are destroyed.
80108
* an issues with GhostPresentationGameObjectSystem throwing exceptions trying accessing ComponentLookup after structural changes.
@@ -93,11 +121,10 @@ uid: changelog
93121
* an issue when using custom templates for type that handle different smoothing options. This was failing validation and causing compilation error, even when it was not the case.
94122
* Case where `GhostUpdateSystem.RestorePredictionBackup` would cause change version changes on unchanged child components (as `PredictionBackupJob` was not updating the `childChangeVersions` pointer when `HasGhostFields == 0 && SerializesEnabledBit != 0`).
95123
* "Size limitation on snapshot did not prevent all errors" and improper serialization of a ghost group root when the group is empty and the available space in the data stream is not enough to encode the length of the group (0, that takes 2 bits).
96-
* missing reset of the entity sent state when a group fail to serialize. The serialized children entity were incorrectly reported to be sent, potentially causing improper baseline used by the server to delta compress the data.
97-
* incorrect warning message when run in background is disable.
124+
* Missing reset of the entity sent state when a group fail to serialize. The serialized children entity were incorrectly reported to be sent, potentially causing improper baseline used by the server to delta compress the data.
125+
* Incorrect warning message when run in background is disable.
98126
* Esoteric `IBufferElementData` serialization issue caused by an incorrect assumption that `stackalloc` would default init its elements.
99127

100-
101128
## [1.4.0] - 2024-11-14
102129

103130
### Added

Documentation~/TableOfContents.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
* [Setting up client and server worlds](set-up-client-server-worlds.md)
44
* [Client and server worlds networking model](client-server-worlds.md)
55
* [Network protocol checks](network-protocol-checks.md)
6+
* [Netcode for Entities multi-driver architecture](networking-network-drivers.md)
7+
* [Use Unity Relay with Netcode for Entities](networking-using-relay.md)
68
* [Creating multiplayer gameplay](creating-multiplayer-gameplay.md)
79
* [Connecting server and clients](network-connection.md)
810
* [Synchronizing states and inputs](synchronization.md)

Documentation~/filter.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,6 @@ apiRules:
2323
- exclude:
2424
uidRegex: \.OnInspectorGUI$
2525
type: Method
26-
- exclude:
27-
uidRegex: .*Tests.*
28-
type: Namespace
2926
- exclude:
3027
uidRegex: \.__COMMAND_NAMESPACE__$
3128
type: Namespace
@@ -38,4 +35,21 @@ apiRules:
3835
- exclude:
3936
uidRegex: \.ToString$
4037
type: Method
41-
38+
- exclude:
39+
uidRegex: ^Unity\.NetCode\.Tests\.FixedListComplexData.*$
40+
type: Struct
41+
- exclude:
42+
uidRegex: ^Unity\.NetCode\.Tests\.HybridComponentWeWillOverride$
43+
type: Class
44+
- exclude:
45+
uidRegex: ^Unity\.NetCode\.Tests\.SimpleData.*$
46+
type: Struct
47+
- exclude:
48+
uidRegex: ^Unity\.NetCode\.Tests\.FixedElement8.*$
49+
type: Struct
50+
- exclude:
51+
uidRegex: ^Unity\.NetCode\.Tests\.Nested.*$
52+
type: Struct
53+
- exclude:
54+
uidRegex: ^Unity\.NetCode\.Tests\.(.*)(Variant|Variation).*$
55+
type: Struct

Documentation~/ghost-snapshots.md

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,68 @@ E.g. `NetworkTickRate:30Hz`, `MaxSendRate:45` means 30Hz is the actual maximum s
4545
* __Dynamic__: The ghost is optimized for a small snapshot size when both changing and not changing.
4646
* __Static__: The ghost isn't optimized for a small snapshot size when changing, but isn't sent at all when it's not changing.
4747

48+
## Structural changes on instantiated ghosts
49+
50+
You can make some structural changes to already instantiated ghost prefabs, such as [adding or removing components](#add-or-remove-components-on-an-instantiated-prefab) or [adding, removing, or destroying child entities](#add-remove-or-destroy-child-entities-on-an-instantiated-prefab), although there are limitations.
51+
52+
| Action | Supported | Limitations |
53+
|------------------------------------------------|------------|----------------------------------------------------------------------------|
54+
| Add or remove components or buffers | Yes | None | |
55+
| Add or remove replicated components or buffers | Yes | Refer to [adding or removing components](#add-or-remove-components-on-an-instantiated-prefab) |
56+
| Add, remove, or destroy child entities | Yes | Refer to [adding, removing, or destroying child entities](#add-remove-or-destroy-child-entities-on-an-instantiated-prefab) |
57+
58+
> [!NOTE]
59+
> Adding, removing, or destroying child entities is not technically a structural change, but has implications for replication.
60+
61+
### Add or remove components on an instantiated prefab
62+
63+
You can add or remove any user-side components from both the root and child entities of an instantiated prefab and serialization and deserialization of the ghost, as well as delta compression, will continue to work.
64+
65+
However, adding a component to an instantiated ghost (even if it has a `[GhostField]`), will not replicate the component to other instances of the same ghost prefab. For a component to be replicated, it must be part of the prefab at authoring time.
66+
67+
### Add, remove, or destroy child entities on an instantiated prefab
68+
69+
You can't remove or change the index of any replicated child entity within the `LinkedEntityGroup` buffer, since doing so can cause serialization and deserialization errors. You can, however, do the following:
70+
71+
* Destroy any child entity in the `LinkedEntityGroup`, with or without replicated components, as long as you don't re-order or remove the associated entry in the `LinkedEntityGroup`.
72+
* Remove entities from the `LinkedEntityGroup` buffer, as long as doing so doesn't cause a re-ordering of the original replicated child entities.
73+
* Append entities to the `LinkedEntityGroup`.
74+
* In general, avoid prepending or inserting entities in between the original entries of the `LinkedEntityGroup` buffer. However, you can insert an entity in the `LinkedEntityGroup` after the last children that has replicated components.
75+
76+
Refer to the following examples of valid and invalid configurations for more details:
77+
78+
```
79+
// This is a valid configuration, where (*) denotes a destroyed entity.
80+
root
81+
child 1 (*) <-- Replicated
82+
child 2
83+
child 3 <-- Replicated
84+
child 4 (*)
85+
86+
// This is a valid configuration, where entities have been appended.
87+
root
88+
child 1 <-- Replicated
89+
child 2 <-- Replicated
90+
=-----= Append / Remove after here
91+
child 3
92+
user entity 1
93+
user entity 2
94+
95+
// This is an invalid configuration because entities have been prepended, changing the index.
96+
root
97+
new user entity 1 <--- INVALID, break replicated entity indexes
98+
child 1 <-- Replicated
99+
child 2 <-- Replicated
100+
child 3
101+
102+
// This is an invalid configuration, because entities have been added in between original entries, changing the index.
103+
root
104+
child 1 <-- Replicated
105+
new user entity 1 <--- INVALID, break replicated entity indexes
106+
child 2 <-- Replicated
107+
child 3
108+
```
109+
48110
## Synchronize ghost components and fields
49111

50112
Netcode for Entities uses C# attributes to configure which components and fields to synchronize as part of a ghost.

0 commit comments

Comments
 (0)