From ecc526d653afd7ce46a09ef835ccb79f336858e9 Mon Sep 17 00:00:00 2001 From: Julia Butenhoff Date: Mon, 6 Dec 2021 14:16:34 -0600 Subject: [PATCH] Corrected player despawning wrong player - Still won't properly despawn if not host though --- Assets/Scripts/Game/EndCollider.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Assets/Scripts/Game/EndCollider.cs b/Assets/Scripts/Game/EndCollider.cs index 5cb544f..dc8e4d9 100644 --- a/Assets/Scripts/Game/EndCollider.cs +++ b/Assets/Scripts/Game/EndCollider.cs @@ -8,7 +8,9 @@ public class EndCollider : MonoBehaviour { // When player collides with the trigger for the end zone private void OnTriggerEnter(Collider other) { - RunnerFinishedMapServerRPC(); + if (other.gameObject.transform.parent.gameObject.GetComponent().OwnerClientId == NetworkManager.Singleton.LocalClientId) { + RunnerFinishedMapServerRPC(); + } } [ServerRpc(RequireOwnership = false)] @@ -22,7 +24,7 @@ public class EndCollider : MonoBehaviour { // Player found // Despawn them - character.GetComponent().Despawn(true); + character.GetComponent().Despawn(); // Update the player data such that Finished is true if (ServerGameNetPortal.Instance.clientIdToGuid.TryGetValue(serverRpcParams.Receive.SenderClientId, out string clientGuid)) { @@ -56,7 +58,10 @@ public class EndCollider : MonoBehaviour { foreach (GameObject character in playableCharactersPostRemove) { if (character.name == "PlayerPrefab") { - FindObject(character, "PlayerCam").SetActive(true); + if (FindObject(character, "PlayerCam") == null) + { + Debug.LogError("NULL"); + } } }