Skip to content

Commit 58aefa9

Browse files
committed
Stop changeownership message on spawn
1 parent d0e8d14 commit 58aefa9

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -628,7 +628,10 @@ public bool SetOwnershipLock(bool lockOwnership = true)
628628
RemoveOwnershipExtended(OwnershipStatusExtended.Locked);
629629
}
630630

631-
SendOwnershipStatusUpdate();
631+
if (IsSpawned)
632+
{
633+
SendOwnershipStatusUpdate();
634+
}
632635

633636
return true;
634637
}

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,6 @@ private void SpawnNetworkObjectLocallyCommon(NetworkObject networkObject, ulong
11181118
return;
11191119
}
11201120

1121-
networkObject.IsSpawned = true;
11221121
networkObject.IsSceneObject = sceneObject;
11231122

11241123
// Always check to make sure our scene of origin is properly set for in-scene placed NetworkObjects
@@ -1151,6 +1150,8 @@ private void SpawnNetworkObjectLocallyCommon(NetworkObject networkObject, ulong
11511150
{
11521151
networkObject.SetOwnershipLock();
11531152
}
1153+
1154+
networkObject.IsSpawned = true;
11541155
SpawnedObjects.Add(networkObject.NetworkObjectId, networkObject);
11551156
SpawnedObjectsList.Add(networkObject);
11561157

@@ -2228,14 +2229,15 @@ internal void SynchronizeObjectsToNewlyJoinedClient(ulong newClientId)
22282229
{
22292230
if (networkObject.Observers.Contains(newClientId))
22302231
{
2231-
if (NetworkManager.LogLevel <= LogLevel.Developer)
2232-
{
2233-
// Temporary tracking to make sure we are not showing something already visibile (should never be the case for this)
2234-
Debug.LogWarning($"[{nameof(SynchronizeObjectsToNewlyJoinedClient)}][{networkObject.name}] New client as already an observer!");
2235-
}
2236-
// For now, remove the client (impossible for the new client to have an instance since the session owner doesn't) to make sure newly added
2237-
// code to handle this edge case works.
2238-
networkObject.Observers.Remove(newClientId);
2232+
// if (NetworkManager.LogLevel <= LogLevel.Developer)
2233+
// {
2234+
// // Temporary tracking to make sure we are not showing something already visibile (should never be the case for this)
2235+
// Debug.LogWarning($"[{nameof(SynchronizeObjectsToNewlyJoinedClient)}][{networkObject.name}] New client as already an observer!");
2236+
// }
2237+
// // For now, remove the client (impossible for the new client to have an instance since the session owner doesn't) to make sure newly added
2238+
// // code to handle this edge case works.
2239+
// networkObject.Observers.Remove(newClientId);
2240+
continue;
22392241
}
22402242
networkObject.NetworkShow(newClientId);
22412243
}

0 commit comments

Comments
 (0)