Why isnt the attack on Input.GetMouseButtonDown(0)

was wondering why we need to to add a throttle when we could just make the attack on the mouse button click?

 public void Attack(CombatTarget conbatTarget)
        {
            GetComponent<ActionScheduler>().StartAction(this);
            target = conbatTarget.transform;
            //my code example
            var distance = Vector3.Distance(transform.position, target.position);
            AttackBehavior(distance);
        }

        private void AttackBehavior(float distance)
        {
            if (distance <= weaponRange)
            {
                GetComponent<Animator>().SetBool("attack", true);
            }
        }

so is it ok to sort of use our own code or will it cause problems further along the course?

Thanks
Darrin

You can do that, if you want.
There are a few issues to watch out for…

  • If you trigger an attack before the attack finishes, it will invoke another trigger which will need to be reset before the animator will attack again.
  • You could wind up with an imbalance if the Enemy attacks at a throttled rate, but the player attacks virtually unlimited.
  • Akin to that, you’ll need to move the decision to actually attack into the Enemy controller instead of in Fighter. This method allows one method to rule them all.
1 Like

Thanks for your reply, i noticed that further along the course,
Maybe for the future when they are teaching they could add we are doing it this way because further doan the line we will be doing this etc

Darrin

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms