private void OnTriggerExit2D(Collider2D other) { if (tagsToDetect.Count > 0 && !tagsToDetect.Contains(other.tag)) { return; } if (!_detected.Contains(other.gameObject)) { return; } _detected.Remove(other.gameObject); onOutOfSight?.Invoke(other.gameObject); }
private void OnTriggerEnter2D(Collider2D other) { if (tagsToDetect.Count > 0 && !tagsToDetect.Contains(other.tag)) { return; } if (_detected.Contains(other.gameObject)) { return; } _detected.Add(other.gameObject); onDetect?.Invoke(other.gameObject); }