fix: #3528 NPC 'isOwned' / 'hasAuthority' now evaluate to true on the server/host

This commit is contained in:
mischa 2023-06-27 12:07:16 +08:00
parent 020c514f9a
commit 532e3e860c

View File

@ -1399,6 +1399,11 @@ static void SpawnObject(GameObject obj, NetworkConnection ownerConnection)
if (ownerConnection is LocalConnectionToClient)
identity.isOwned = true;
// NPCs (objects without an owner connection) are owned by the server.
// fixes: https://github.com/MirrorNetworking/Mirror/issues/3528
if (ownerConnection == null)
identity.isOwned = true;
// only call OnStartServer if not spawned yet.
// check used to be in NetworkIdentity. may not be necessary anymore.
if (!identity.isServer && identity.netId == 0)