private void OnTriggerEnter(Collider other) { if (other.tag != "Enemy") { return; } OnEnemyDetected?.Invoke(this, null); }
private void CheckUnit() { var _enemiesInRange = Physics.OverlapSphere(transform.position, _stats.UnitRange, _enemy); if (_enemiesInRange.Length == 0) { return; } _closestEnemy = _enemiesInRange.OrderBy(c => Vector3.Distance(transform.position, c.transform.position)).First().gameObject; OnEnemyDetected?.Invoke(_closestEnemy); }