Making the enemies destructible
Recall that in earlier chapters, we created enemy targets that the player could destroy after a couple of hits with a projectile. We want to give the player a similar ability to mitigate the threat provided by our new enemies. To do so, we will add blueprint nodes in BP_EnemyCharacter
to handle damage-taking and destruction. The player needs to hit an enemy character three times to destroy them.
Follow these steps to deal with a hit:
- In the content browser, access the
Content > FirstPersonBP > Enemy
folder and double-click on theBP_EnemyCharacter
blueprint. - In the Variables category of the My Blueprint panel, click the + button to add a variable, and name the variable
EnemyHealth
. - In the Details panel, set Variable Type to Integer. Compile the blueprint and set DEFAULT VALUE to
3
:
- Right-click on the empty space of Event Graph and add an...