Stop Ai BT Branch When Player Dead

Hello Friends,

I have my Ai running a behaviour tree including a patrol, chase player, search for and attack etc.
My Ai also uses the Ai Perception component.

When an NPC Ai kills my character I need to be able to tell that to the NPC and make it return to its patrol. At the moment when my player dies the NPC gets stuck on the attacking player branch for which has existing conditions to be met therefore I believe I need a service or similar on the branch that goes to attack my player checking to see if the player’s HP is 0 (or something).

Can anyone help?

Thanks in advance.

I have figured this out. If anyone has same issue here is what I did:

Simply create a new BTTask that casts to you player and checks if HP is <= 0. If so it will abort chasing the player and return to patrol.

More info upon request.

2 Likes