How to cancel a task correctly? (Behavior tree -> MoveTo)

I’m testing this simple behavior tree.

The thing is, stopping the task (Move to) is a pain.

In the first case: (Decorators without abort self option)
Decorators don’t work until the task fails or reaches the goal…
So in this case they are not useful to stop the task.

In the second case: (Decorators with abort self option)
Decorator aborts task continually. The bot has not a continuous movement.
I don’t want this either… it doesn’t seem natural.

Neither of the two behaviors above are useful.
I simply want to abort the task immediately when the variable is not set.
What is the trick to do it well?
Thank you so much!!

Ok… this way seems to work well
-Aborts lower priority and reorganize branches like this.

The previous solution is not feasible for large trees.
If anyone knows a better way please let me know.

Thank you!!


i see a lot of people are totally lost tryding to stop “MoveTo” since teen years ago… :scream:


there is an execute abort or similiar node, on that you can call stopallmovementimmediately()

1 Like

Thank you so much for that alternative solution. :heart:

Seem there is several ways to do it… But also seem each one work in a different scenario.

That explains why over 10 years people came up with so many different solutions.

I use a btservice to update stop move or not,use a blackboard decorator to stop moveto node,and use forcesuccess decorator to force stopmove node success,so the following nodes can be executed.And don’t forget to call stopmove so the AIMoveto Task (back in the moveto node)will stop.
BTExampleStopMove