Why do you need to check if CanAttck if the fighter script already checks it?

if (InAttackRangeOfPlayer() && fighter.CanAttack(player))
{
fighter.Attack(player);
}

that’s what you wrote

I’m not sure if we’re there yet in this lecture, but CanAttack() checks to see if there is a valid path, and if the target (the player in this case) is even alive. It’s like a pre-check before we go and reset other logic in the game. (Fighter.Attack() will reset other actions like moving somewhere on patrol, for example).

Got it . TNX

Privacy & Terms