From 62f6073fadcb0f887e53203f19d828f07c118344 Mon Sep 17 00:00:00 2001 From: NIMFER Date: Sat, 28 Aug 2021 12:44:09 +0200 Subject: [PATCH] Tap update --- Assets/Scripts/Trap.cs | 45 ++++++++++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/Assets/Scripts/Trap.cs b/Assets/Scripts/Trap.cs index 564f766..640edb0 100644 --- a/Assets/Scripts/Trap.cs +++ b/Assets/Scripts/Trap.cs @@ -30,6 +30,9 @@ public class Trap : MonoBehaviour [Header("Trap settings")] + public LayerMask player; + public LayerMask robber; + [Dropdown("trapTypes")] public string trapType; private string[] trapTypes = new string[] { "Pinns", "Rope", "Ladder", "Bear Trap", "Bannana Peal" }; @@ -103,20 +106,26 @@ public class Trap : MonoBehaviour private void FixedUpdate() { - if (Physics.CheckSphere(transform.position + trapInteractionRadiusOffset, trapInteractionRadius)) + if (Physics.CheckSphere(transform.position + trapInteractionRadiusOffset, trapInteractionRadius, player)) { - switch (interacted) - { - case 1: - Debug.Log("trap collected"); - isSet = false; - GetComponent().sharedMaterial = setMaterial; - break; - case 0: - //Debug.Log("player in range"); - break; - } + playerInRange = true; + + } + else + { + playerInRange = false; + } + + if (Physics.CheckSphere(transform.position + trapInteractionRadiusOffset, trapInteractionRadius, player)) + { + + playerInRange = true; + + } + else + { + playerInRange = false; } } @@ -127,7 +136,17 @@ public class Trap : MonoBehaviour if (playerInRange) { - + switch (interacted) + { + case 1: + Debug.Log("trap collected"); + isSet = false; + GetComponent().sharedMaterial = setMaterial; + break; + case 0: + //Debug.Log("player in range"); + break; + } } if (robberInRange)