Creating an enemy attack
If the enemies we create are going to pose a genuine obstacle to 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 element to this attack, ensuring that there is some consequence of the enemy reaching the melee range of the player.
Making an attack task
We will create an attack task named BTTask_DoAttack
that does damage, and we will extend the Attack Player sequence we created in the enemy Behavior Tree. The task will have two variables – one to store the target of the damage and one to store the amount of damage to be applied.
Follow these steps to create the attack task:
- In the content browser, access the
Content/FirstPersonBP...