What happens, in a behavior tree, when a priority node chooses another branch over a running branch?
Small example:
Priority 1: Fight
Sequence:
-Enemy near?
-Fight!
Priority 2: Move
Sequence:
-Is there a hole?
-Jump!
Run 5m!
Now in the first iteration there is no enemy, but a hole, so the action Jump!
gets executed. It's a rather lengthy animation so it returns running.
For what should happen in the next iteration I found kind of contradictory statements. According to this answer the priority node always begins at the first priority disregarding if another priority is running. In this article however while the examples follow the same scheme, the explanation also mentions that it's possible to lock the tree in the Running
state until it's finished.
If the tree is locked in the Running
behavior, the character can't react until he walked all the way to his walking target, so this can't be the right interpretation.
If always the first priority gets checked again, the character can react to enemies while he's running (he stops and fights) - that's the desired behavior. If however he's in the air jumping, he can not just stop and fight, he has to land first, so this time I can't choose priority Fight
over Move
!
How should I handle those cases? Am I even approaching it the right way?
can react?
in all other priorities, but that seems to be a clumsy solution. \$\endgroup\$