Skip to content

Commit c632b13

Browse files
fix: distributable or sessionowner flag always defaults for in-scene placed NetworkObjects (#3407)
This PR removes the opinionated restrictions to permissions with in-scene placed NetworkObjects and matches the DAHost redistribution logic to mirror the rust server's when a client disconnects. [MTT-11973](https://jira.unity3d.com/browse/MTT-11973) ## Changelog - Fixed: Issue where root level in-scene placed `NetworkObject`s would only allow the ownership permission to be no less than distributable or sessionowner. ## Testing and Documentation - No tests have been added (requires manually testing in-editor) - No documentation changes or additions were necessary. <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> ## Backport No backport is needed since this is a distributed authority specific fix.
1 parent 0eec5e2 commit c632b13

File tree

3 files changed

+5
-16
lines changed

3 files changed

+5
-16
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1313

1414
### Fixed
1515

16+
- Fixed issue where root level in-scene placed `NetworkObject`s would only allow the ownership permission to be no less than distributable or sessionowner. (#3407)
1617

1718
### Changed
1819

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

+4-7
Original file line numberDiff line numberDiff line change
@@ -1195,16 +1195,13 @@ internal void OnClientDisconnectFromServer(ulong clientId)
11951195
}
11961196
else if (!NetworkManager.ShutdownInProgress)
11971197
{
1198-
// DANGO-TODO: We will want to match how the CMB service handles this. For now, we just try to evenly distribute
1199-
// ownership.
1200-
// NOTE: All of the below code only handles ownership transfer.
1198+
// NOTE: All of the below code only handles ownership transfer
12011199
// For client-server, we just remove the ownership.
1202-
// For distributed authority, we need to change ownership based on parenting
1200+
// For distributed authority (DAHost only), we only transfer objects that are not parented or belong to the session owner.
1201+
// Rust server handles the object redistribution on its end.
12031202
if (NetworkManager.DistributedAuthorityMode)
12041203
{
1205-
// Only NetworkObjects that have the OwnershipStatus.Distributable flag set and are not OwnershipSessionOwner are distributed.
1206-
// If the object has a parent - skip it for now, it will be distributed when its root parent is distributed.
1207-
if (!ownedObject.IsOwnershipDistributable || ownedObject.IsOwnershipSessionOwner || ownedObject.GetCachedParent())
1204+
if (ownedObject.IsOwnershipSessionOwner || ownedObject.GetCachedParent())
12081205
{
12091206
continue;
12101207
}

com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs

-9
Original file line numberDiff line numberDiff line change
@@ -325,15 +325,6 @@ private void CheckForInScenePlaced()
325325

326326
// Default scene migration synchronization to false for in-scene placed NetworkObjects
327327
SceneMigrationSynchronization = false;
328-
329-
// Root In-scene placed NetworkObjects have to either have the SessionOwner or Distributable permission flag set.
330-
if (transform.parent == null)
331-
{
332-
if (!Ownership.HasFlag(OwnershipStatus.SessionOwner) && !Ownership.HasFlag(OwnershipStatus.Distributable))
333-
{
334-
Ownership |= OwnershipStatus.Distributable;
335-
}
336-
}
337328
}
338329
}
339330
#endif // UNITY_EDITOR

0 commit comments

Comments
 (0)