Skip to content

fix: distributable or sessionowner flag always defaults for in-scene placed NetworkObjects #3407

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
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
1 change: 1 addition & 0 deletions com.unity.netcode.gameobjects/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Fixed

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

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1195,16 +1195,13 @@ internal void OnClientDisconnectFromServer(ulong clientId)
}
else if (!NetworkManager.ShutdownInProgress)
{
// DANGO-TODO: We will want to match how the CMB service handles this. For now, we just try to evenly distribute
// ownership.
// NOTE: All of the below code only handles ownership transfer.
// NOTE: All of the below code only handles ownership transfer
// For client-server, we just remove the ownership.
// For distributed authority, we need to change ownership based on parenting
// For distributed authority (DAHost only), we only transfer objects that are not parented or belong to the session owner.
// Rust server handles the object redistribution on its end.
if (NetworkManager.DistributedAuthorityMode)
{
// Only NetworkObjects that have the OwnershipStatus.Distributable flag set and are not OwnershipSessionOwner are distributed.
// If the object has a parent - skip it for now, it will be distributed when its root parent is distributed.
if (!ownedObject.IsOwnershipDistributable || ownedObject.IsOwnershipSessionOwner || ownedObject.GetCachedParent())
if (ownedObject.IsOwnershipSessionOwner || ownedObject.GetCachedParent())
{
continue;
}
Expand Down
9 changes: 0 additions & 9 deletions com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,6 @@ private void CheckForInScenePlaced()

// Default scene migration synchronization to false for in-scene placed NetworkObjects
SceneMigrationSynchronization = false;

// Root In-scene placed NetworkObjects have to either have the SessionOwner or Distributable permission flag set.
if (transform.parent == null)
{
if (!Ownership.HasFlag(OwnershipStatus.SessionOwner) && !Ownership.HasFlag(OwnershipStatus.Distributable))
{
Ownership |= OwnershipStatus.Distributable;
}
}
}
}
#endif // UNITY_EDITOR
Expand Down