So real quick I’ve got a few questions. Bools are still catching me and I’m a little confused.
-
Why do we put in the parameter of CombatTarget combatTarget to the bool, is there a reason for that rather than just getting the CombatTarget component inside of CanAttack or something?
-
When we just type “return” followed by targetToTest != null && !targetToTest.isDead() is that basically just saying “return true if both statements are true”? Would it be okay to type out something like “if(targetToTest !=null && !targetToTest.isDead()) return true;”? Is that basically the same thing?
-
What is the reason to create a reference to Health in CanAttack vs using the Health reference (target) at the top of the class? I tried that and my player just attacked automatically as soon as he was in range of a target, but I couldn’t parse through the logic. Would I be able to—like in the Health script—add a bool called canAttack at the top of the class and set up “CanAttack” the same way?
Could someone help? Thank you so much! Loving this course.