public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator.IsInTransition(layerIndex))
        {
            return;
        }

        _target = _brain.GetCurrentTarget();

        if (_target is null)
        {
            return;
        }

        // See if we can use our special attack
        if (_combat.CanUseSpecialAttack)
        {
            _combat.SpecialAttack();
            return;
        }

        float distance = Vector3.Distance(animator.transform.position, _target.position);

        // Try to attack player if they are close enough
        if (distance <= _brain.attackRadius)
        {
            if (Vector3.Angle(_target.position - animator.transform.position, animator.transform.forward) > angleFromTargetTolerance)
            {
                animator.SetTrigger("Rotate");
                return;
            }

            if (!_combat.IsCoolingDown)
            {
                // Go to attack state
                _combat.ChooseAttack();
                return;
            }
        }

        // Move to target player if necessary
        if (distance > _agent.stoppingDistance)
        {
            animator.SetTrigger("Follow");
        }
    }
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator.IsInTransition(layerIndex))
        {
            return;
        }

        _target = _brain.GetCurrentTarget();

        if (_target is null)
        {
            return;
        }

        float distance = Vector3.Distance(animator.transform.position, _target.position);

        // Try to attack player if they are close enough
        if (distance <= _brain.attackRadius)
        {
            if (canRotate && Vector3.Angle(_target.position - animator.transform.position, animator.transform.forward) > angleFromTargetTolerance)
            {
                animator.SetTrigger("Rotate");
                return;
            }

            if (!_combat.IsCoolingDown)
            {
                // Go to attack state
                bool choseAttack = _combat.ChooseAttack();

                if (choseAttack)
                {
                    return;
                }
            }
        }

        // Follow player if possible and necessary
        if (canFollow && distance > _agent.stoppingDistance)
        {
            animator.SetTrigger("Follow");
        }
    }
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator.IsInTransition(layerIndex))
        {
            return;
        }

        _target = _brain.GetCurrentTarget();

        if (_target is null && !_agent.hasPath)
        {
            animator.SetTrigger("Idle");
            return;
        }

        if (_agent.enabled && _target)
        {
            // See if we can use our special attack
            if (_combat.CanUseSpecialAttack)
            {
                _combat.SpecialAttack();
                return;
            }

            if (!_combat.IsCoolingDown && Vector3.Distance(_target.position, animator.transform.position) <= _brain.attackRadius)
            {
                // Go to attack state
                bool choseAttack = _combat.ChooseAttack();

                if (choseAttack)
                {
                    return;
                }
            }
        }

        animator.SetFloat("WalkSpeed", _agent.velocity.magnitude);
    }