I am fairly new to UE, start using it for couple of months now.
Recently I have started to try out AI part of Unreal engine, and started of by watching and read some of AI tutorials I could find.
On a press of a keyboard button I have set the state/affiliation of a player toward AI character, toggles me as friendly or enemie.
In my AIController I have added AIPerception component, then I have made simple Behavior tree for my AI character:
I noticed when I set player as ENEMY he doesn’t switch to left branch (go toward player) until all of task in WANDER branch are done complete.
My question is, how can I interrupt right side branch to stop what is doing and switch to left one immediately?
Hey, so this is thankfully quite easy. On your decorator, if you select it, there’s the notify observer, and observer aborts options. You want to choose to abort lower priority on your left chain, which should be the more important side. Since the execution flows left to right, make the important stuff on the left, and the abort will make it eject anything to the right of it to immediately play itself.
I already got it set up:
But it won’t get to that point until all tasks are finished for that pass, I can’t interrupt it in the middle.
I don’t see the way how this can be done. Maybe I should make each WANDER task custom and add ReceiveTickAI and check if key is set, then StopMovement → FinishExecute ?
The abort should interrupt it even in the middle of a task, try changing the notify observer to OnValueChanged, see if that makes it work