Esempio n. 1
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.tag != "Enemy")
        {
            return;
        }

        OnEnemyDetected?.Invoke(this, null);
    }
Esempio n. 2
0
    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);
    }