Download

Handling AI Death in Blueprint

It’s probably partially my newness to BTs from FSMs, but I’m having trouble setting up dying and dead “states” to my AI’s behavior tree. When the AI’s health reaches 0, I want to play a dying animation. After the animation’s played, I want the enemy to fade out and delete himself (and the AI controller, weapon, pawn etc…). I could hack this together in the AI controller, but I’m really giving behavior trees a chance. My gut tells me that I should be using behavior trees for this. I appreciate any tips, or examples. I currently set a Blackboard Key ‘Dead = True’ in the AI controller when health <= 0, then “listen” for that Dead key in the BT.

Here’s my behavior tree currently, I’m sure I’m doing it wrong. All of it works fine except for the Dying part.
fab5ce15c0ec92380f1c5110418deb98b166b318.png

I would do the death in the BP itself. Much easier.

If “Health” =< 0 then “Play Anim Montage” Then “Delay” to allow montage to finish, then “Destroy Actor”

Narg

I set that up and it works fine. I just it in the controller. However, the BT keeps going, so while the death animation montage is playing, the AI is still following me around the level. Is there a way to stop the BT before I play the montage?

Figured it out. I changed some stuff up (added a search for player behavior, and a wander behavior). Then I also added a death check, and if it fails that, it goes into the death behavior.
4e717cdc8e1329a00bf85acd85b0a28a6793bb5a.png

i have the same issue, Can you share more info on how you got this done? I ma new to UE4 and creating Games. So far i have this in BP but player follows me after the montage is done