Activate BehaviorTree on being hit?

Hi! I have made a working behaviourtree that makes the AI patroll and attack the player on LOS but i want it to attack the player if the player shoots it. how can i make a envent in the BehaviorTree that is "on beeing hit?

Best regards!

Add a “Was Hit” key to your AI’s Blackboard asset, set that key when AI is being shot at and use “Blackboard” decorator in your BT to observe that specific key. If you put “reaction” branch on the left of the three, which means it has a high priority, and condition it with this kind of decorator, and make that decorator “abort lower priority” then that reaction branch will get activated as soon as AI is being shot at.

Cheers,

–mieszko

Thanks so much for the help. just need to figureout how to set the blackboard key in my blueprint. but the behaviourtree works!

Thanks again!

One more question. Can i set a blackboard key in a Pawn blueprint? because everytime i try the editor crashes and it don’t seems to change the value of the key.

Best regards!

Solved it made a litteral name so it worked

Can you give more details on the crashing part? I’d like to address is so that users don’t crash even if they misuse it. Thanks advance!

The Edior crashes when i tried to set the “washit” variable as a blackboard value as value. in the AI category in the context menu. If i try to set it this way it crashes. But when i set it as the other choice “Blackboard component” it worked. This is set in a regular character blueprint and not in the behaviour tree which can be the problem since it says that its connected to the behaviour tree.

hopes this helps!

I know what’s that bug. It has been already reported. The problem is you have “context sensitive” disabled on your context menu so you got something unusable in given context - the one that crashes is BT-specific implementation and should fail to compile when used anywhere else. The bug is that it doesn’t fail the compilation (a BP compiler bug).
Thanks for reporting though!