Skip to content

Commit 81a88fc

Browse files
update
When a session owner leaves, any remaining in-scene placed NetworkObjects belonging to the session owner changes ownership over to the newly promoted session owner. (temporary solution for this type of ownership change)
1 parent bcf94a7 commit 81a88fc

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,24 @@ public bool DAHost
132132

133133
internal void SetSessionOwner(ulong sessionOwner)
134134
{
135+
var previousSessionOwner = CurrentSessionOwner;
135136
CurrentSessionOwner = sessionOwner;
136137
LocalClient.IsSessionOwner = LocalClientId == sessionOwner;
138+
if (LocalClient.IsSessionOwner)
139+
{
140+
foreach (var networkObjectEntry in SpawnManager.SpawnedObjects)
141+
{
142+
var networkObject = networkObjectEntry.Value;
143+
if (!networkObject.IsSceneObject.Value)
144+
{
145+
continue;
146+
}
147+
if (networkObject.OwnerClientId != LocalClientId)
148+
{
149+
SpawnManager.ChangeOwnership(networkObject, LocalClientId, true);
150+
}
151+
}
152+
}
137153
}
138154

139155
// TODO: Make this internal after testing

0 commit comments

Comments
 (0)