Skip to content

Commit 4a1c2ff

Browse files
fix: Do not propagate in-scene value to dynamically spawned children [MTT-5357] (#2396)
* fix This resolves the issue with dynamically spawned NetworkObjects that are parented under an in-scene placed NetworkObject would be marked as in-scene placed and cause client-side soft synchronization issues due to the client looking for an in-scene placed NetworkObject that was actually dynamically spawned. * test Added integration test to validate this fix. This tests that both players and dynamically spawned NetworkObjects that are parented under in-scene placed NetworkObjects works and that late joining clients properly synchronize the parented status. This also validates an advanced parenting sample in our documentation works. * udpate MTT-5357 Adding the fix to the changelog. --------- Co-authored-by: Unity Netcode CI <[email protected]>
1 parent 66b11d0 commit 4a1c2ff

File tree

9 files changed

+1299
-0
lines changed

9 files changed

+1299
-0
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ Additional documentation and release notes are available at [Multiplayer Documen
2121
- Network prefabs are now stored in a ScriptableObject that can be shared between NetworkManagers, and have been exposed for public access. By default, a Default Prefabs List is created that contains all NetworkObject prefabs in the project, and new NetworkManagers will default to using that unless that option is turned off in the Netcode for GameObjects settings. Existing NetworkManagers will maintain their existing lists, which can be migrated to the new format via a button in their inspector. (#2322)
2222

2323
### Fixed
24+
2425
- Fixed issue where changes to a layer's weight would not synchronize unless a state transition was occurring.(#2399)
2526
- Fixed issue where `NetworkManager.LocalClientId` was returning the `NetworkTransport.ServerClientId` as opposed to the `NetworkManager.m_LocalClientId`. (#2398)
27+
- Fixed issue where a dynamically spawned `NetworkObject` parented under an in-scene placed `NetworkObject` would have its `InScenePlaced` value changed to `true`. This would result in a soft synchronization error for late joining clients. (#2396)
2628
- Fixed a UTP test that was failing when you install Unity Transport package 2.0.0 or newer. (#2347)
2729
- Fixed issue where `NetcodeSettingsProvider` would throw an exception in Unity 2020.3.x versions. (#2345)
2830
- Fixed server side issue where, depending upon component ordering, some NetworkBehaviour components might not have their OnNetworkDespawn method invoked if the client side disconnected. (#2323)

com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,11 @@ private void SpawnNetworkObjectLocallyCommon(NetworkObject networkObject, ulong
603603
var children = networkObject.GetComponentsInChildren<NetworkObject>();
604604
foreach (var childObject in children)
605605
{
606+
// Do not propagate the in-scene object setting if a child was dynamically spawned.
607+
if (childObject.IsSceneObject.HasValue && !childObject.IsSceneObject.Value)
608+
{
609+
continue;
610+
}
606611
childObject.IsSceneObject = sceneObject;
607612
}
608613
}

0 commit comments

Comments
 (0)