fix(NetworkConnectionToClient): DestroyOwnedObjects use RemovePlayerForConnection for scene objects instead of UnSpawn

- Scene objects need to stay alive for everyone else by default
- Users can choose to Unspawn for themselves.
This commit is contained in:
MrGadget 2024-07-04 10:31:45 -04:00
parent 49ad787d7c
commit 561e33ffea

View File

@ -204,10 +204,9 @@ internal void DestroyOwnedObjects()
{
if (netIdentity != null)
{
// unspawn scene objects, destroy instantiated objects.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3538
// disown scene objects, destroy instantiated objects.
if (netIdentity.sceneId != 0)
NetworkServer.UnSpawn(netIdentity.gameObject);
NetworkServer.RemovePlayerForConnection(this, RemovePlayerOptions.KeepActive);
else
NetworkServer.Destroy(netIdentity.gameObject);
}