From 4568c350bfec91842dc9a8fe0917798fbfce7dda Mon Sep 17 00:00:00 2001 From: Felix Boucher Date: Sun, 12 Nov 2023 20:31:21 -0500 Subject: [PATCH] toggle collider in coroutine instead of script --- Assets/Scripts/Detection.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Assets/Scripts/Detection.cs b/Assets/Scripts/Detection.cs index c3acfcf..5c1339f 100644 --- a/Assets/Scripts/Detection.cs +++ b/Assets/Scripts/Detection.cs @@ -103,14 +103,19 @@ public class Detection : MonoBehaviour if(_projectileDamage == 0) { if ((other.gameObject.tag == "Opponent" && _entityLinked is Ally) || (other.gameObject.tag == "Ally" && _entityLinked is Opponent)) { _entityLinked.IsEnemyDetected = false; - enabled = false; - enabled = true; + StartCoroutine(ToggleCollider()); } } } } + IEnumerator ToggleCollider() + { + _collider.enabled = false; + yield return null; + _collider.enabled = true; + } //Getter and Setter public Entity EntityLinked