If the enemies we create are going to pose a genuine obstacle in the way of the player achieving the goals we create for them, then we will first need to give the enemies the ability to damage the player. In Chapter 9, Building Smart Enemies with Artificial Intelligence, we set up the basic structure of an enemy attack pattern. It is triggered when the player enters the enemy's line of sight. We are now going to introduce a damage Component to this attack, ensuring that there is some consequence of the enemy reaching the melee range of the player.
Creating an enemy attack
Making an attack task
To create an attack task that does damage, we will extend the Attack Player sequence we created in the enemy Behavior Tree. Open...