Example #1
0
    // OnStateUpdate is called on each Update frame between OnStateEnter and OnStateExit callbacks
    override public void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        if (animator.GetFloat("HitCurve") > 0 && !hasHit)
        {
            hasHit = true;
            controller.Attack();
        }

        if (Vector3.Distance(controller.transform.position, controller.target.transform.position) > controller.hitRange / 2)
        {
            animator.SetBool("AttackRange", false);
        }
    }