示例#1
0
    void Update()
    {
        AttackTimer += Time.deltaTime;

        Enemy closest = EnemyInRangeChecker.GetClosestEnemyInRange();

        if (closest != null && rotateToTarget)
        {
            RotateToTarget(closest.gameObject.transform.position);
        }

        if (AttackTimer > delayBetweenAttacks)
        {
            if (!CanAttack())
            {
                return;
            }

            Attack();
            AttackTimer = 0;
        }
    }