From accf84328340cd1fc44231538a26346eef16867f Mon Sep 17 00:00:00 2001 From: vis2k Date: Wed, 10 Mar 2021 23:45:29 +0800 Subject: [PATCH] fix: NetworkIdentity.Reset resets isLocalPlayer AFTER the isLocalPlayer ClearLocalPlayer check. fixes a runtime UnSpawn test. --- Assets/Mirror/Runtime/NetworkIdentity.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Assets/Mirror/Runtime/NetworkIdentity.cs b/Assets/Mirror/Runtime/NetworkIdentity.cs index 63206dcad..e60b84381 100644 --- a/Assets/Mirror/Runtime/NetworkIdentity.cs +++ b/Assets/Mirror/Runtime/NetworkIdentity.cs @@ -1110,7 +1110,7 @@ internal void Reset() clientStarted = false; isClient = false; isServer = false; - isLocalPlayer = false; + //isLocalPlayer = false; <- cleared AFTER ClearLocalPlayer below! netId = 0; connectionToServer = null; @@ -1119,10 +1119,13 @@ internal void Reset() ClearObservers(); + // clear local player if it was the local player, + // THEN reset isLocalPlayer AFTERWARDS if (isLocalPlayer) { NetworkClient.ClearLocalPlayer(); } + isLocalPlayer = false; } // clear all component's dirty bits no matter what