How to stop AI MoveTo on blackboard based condition change

Hi, i got a simple AI setup, but I have the problem to instantly stop AI moving after switching state in Search BTT (after the AI seen player and within the search radius i’ve set). It always required the Patrol BTT on finish execute success before switching to another behavior path (which is the attack state), and resulting the AI doesn’t react to the player unless arrived the destination. Any solution? Thanks.

Behavior Tree

Patrol BTT

Search BTT

One thing you need to keep in mind while structuring your behavior tree is that “higher priority” behaviors should be placed on the left, so that they get processed first. Once you do that mark your BB-observing decorators as “Abort Lower Priority” and as soon as the condition changes in a way that allows underlying branch to run the lower priority branch will get aborted.

A note, while I have your attention, why do you have a sequence that has a single simple-parallel child? The sequence is not needed in this case (it does absolutely nothing).

Cheers,

–mieszko

Well this is now my bt structure,

btw I’ve already set the observer aborts to self and it does abort the path underlying the branch (bbcondition:State = search) once the state switched to “attack”, however the AI MoveTo node in patrol task still somehow executing in the background even it got aborted, the track and attack task running fine tho, the problem is just that the AI must arrive the destination before the character can perform the attack animation.

FYI: The AI Character attack animation will be played by enabling isAttacking to true in character BP. To do this I created a custom event called “Attack” in character BP and call it while the attack task is active. Here is the attack task graph:

Yeah, I probably should have had a look at that Patrol BT task first.

The main issue there is that AI Move To node doesn’t get automatically aborted when you abort a task that has requested it. This node doesn’t talk to BTs at all. You need to manually abort the move as a response to Event Receive Abort AI.

Having said that there’s no BP function for doing that (it’s an oversight!). I’ve filed it as a missing feature. In the mean time try requesting a move to where AI is standing - that should make AI stop :smiley:

Or you can try using BTTask_MoveTo, or implement a class derived from that in C++.

Hi Mieszko, I’m also looking into ways to abort a task while it’s executing. Currently the ‘Receive Abort’ doesn’t get called within the executing task even though the parent tree has called abort on itself and subtrees. Do you know if there are any plans to add support for the same?

Are there any plans to add an abort feature?

Any news on this?