diff --git a/Assets/Mirror/Core/NetworkIdentity.cs b/Assets/Mirror/Core/NetworkIdentity.cs index ff1e1e341..e66977daa 100644 --- a/Assets/Mirror/Core/NetworkIdentity.cs +++ b/Assets/Mirror/Core/NetworkIdentity.cs @@ -674,8 +674,8 @@ internal void OnStopServer() bool clientStarted; internal void OnStartClient() { - if (clientStarted) - return; + if (clientStarted) return; + clientStarted = true; // Debug.Log($"OnStartClient {gameObject} netId:{netId}"); @@ -700,6 +700,10 @@ internal void OnStartClient() internal void OnStopClient() { + // In case this object was destroyed already don't call + // OnStopClient if OnStartClient hasn't been called. + if (!clientStarted) return; + foreach (NetworkBehaviour comp in NetworkBehaviours) { // an exception in OnStopClient should be caught, so that