OK, so I had some trouble figuring this one out, but I think I got it. I’ll do my best to explain.
You’ll need to [create an anim montage][4] if you don’t already have one. Then go into the animation blueprint AnimGraph and add the slot:
I’m going to assume you used the behavior tree [quick start guide][1] from the Docs based on your screenshots and build off of that assumption.
In Blackboard, make a boolean, BoxTriggered in my case.
On Behavior Tree, make a sequence between Chase and Patrol. Give it a Blackboard Decorator for when the new boolean is set:
Then, make a new BTTask:
Have the task play the animation montage on the character, using the return duration for a delay before resetting the blackboard boolean and finishing execution of the task.
Remember to expose the blackboard key (eyeball icon) and set it on the behavior tree task as well.
Then, on the AI Controller, make a function to turn on the BoxTriggered blackboard boolean and turn off the CanSee blackboard boolean (or haslineofsight, whatever you named it):
So now we actually need to fire off the trigger event. I made a new blueprint called BP_MyBoxTrigger based off of the BoxTrigger class. It has no code in it. I just placed it in the world.
On the AI Character, on begin overlap, we check for BP_MyBoxTrigger and if that’s the overlapping class we get the owning controller, cast to our AI controller and fire off that function:
Phew!
Please mark my answer accepted if this has been helpful!
If you have any more questions, feel free to follow up.
Happy developing,
Reishi




