How do I manually abort Move To in Behavior Trees?

Hello,

I have tried many ways to stop the “move to” and “move directly to” tasks once they’ve started, but no matter what I do, they wait until they have reached their targets to stop. This all started because I wanted to check whether there was a path to the player, and if there was, Move To with pathfinding, if there wasn’t, Move Directly Toward without pathfinding (so the AI can walk off ledges at the player. Really, why is there no option to allow this by default without navlinks?) It works as expected the first path check; the AI will see there is a path and follow me, or fall off a ledge at me if there isn’t one. But as soon as the enemy picks a mode, it becomes stuck and never changes modes again unless it touches its goal and considers itself “finished”, no matter what i’ve tried. “Move To” will realize it can’t find a path after some time and abort, but “Move Directly Towards” gets stuck infinitely until it hits its goal. Things I have tried already:

-does path exist? decorators, one normal and one inverse (i have also tried putting these directly on the move nodes)

-checking if there is a path earlier in the sequence, directly setting a blackboard value, then checking it in 2 selectors with aborts self enabled

-simple parallel, with moveTos as the task and an infinite loop checking the blackboard value in the background, like this thread: Getting AI to interrupt/abort Behavior Tree MoveTo Task - #2 by Kilrogg

hopefully somebody can help me out here. I have seen many threads about this from a while back, and people coming through years later asking if a manual abort task was ever implemented, with no responses.

It’s been a hot minute since I’ve dealt with this, but from what I can tell you have set up your move to reach the actor. The condition for path existence is only evaluated to enter the selector. Once it enters it will just run whatever is under it without ever checking.
One means of accomplishing what you want is to have a simple parallel and have the main task be a “wait” task and tack on a “loop infinite” decorator and a “does path exist” decorator and “is not at location” decorator. This will cause the parallel loop to run until the does path exist fails or the not at location fails (meaning arrived). Then the sub task of the parallel node can be your move to.
Note this is a somewhat hacky way to get what you want while avoiding writing custom behavior tree nodes.

1 Like

hello, thank you for the reply. i tried this with the setup here:


but it doesn’t seem to be working as i want. i tried the “is not at location” node also, but it didn’t change anything no matter how i set it. none of those decorators have the ability to “break” it seems.

to better explain what i’d like: if the AI cannot find a valid path to the player, i want them to blindly seek the player’s location using “move directly towards”, which ignores any pathfinding. but as soon as a path is found, i want the AI to instantly swap back to using pathfinding, via the “move to” method. This will let my enemy that is on a ledge for example, drop off onto the floor the player is on (can’t find a path off the ledge, because of how navmesh works), then chase him normally around obstacles.

i might have misunderstood the placement you meant, since this works with one problem


when the wait ends, the enemy will pause, which looks pretty terrible in motion

1 Like

The reason is because you’re using selectors to execute the tasks instead of sequence. When using a selector, the nodes connected to it must have conditions, if not it will always execute.
The behaviour tree doesn’t exactly work like a state machine