Closed nickswebsite closed 1 month ago
After digging a little deeper, it appears that the BTRoot
and the FiniteStateMachine
nodes are fighting each other during the _process_code()
. BTRoot._process_code()
runs after FiniteStateMachine._process_code()
, so BTRoot.current_status
doesn't get updated (and no event is fired) during the frame.
I had to make sure SUCCESS was returned from BTSequence
when the last action was completed successfully, AND alter FSMStateIntegratedBT
in the following manner:
BTRoot.process_mode = Node.PROCESS_MODE_DISABLED
from _ready()
behaviour_tree._process_code(_delta)
during its _on_update()
method.I added an example scene here: https://github.com/ThePat02/BehaviourToolkit/pull/83
BTSequence does not return a SUCCESSful status when the last action is successful. Currently it waits for the next tick to reset itself and report success.
While this doesn't appear to be a problem for trivial cases, when a child node of an FSMStateIntegratedBT that is configured to fire an event on success, the event does not get fired until the first task of the sequence has already run. This is particularly problematic if the first task is intended to check conditions based on the current state of the game world.
The 'minimal' scene setup:
finished
event on success.finished
timeout
Ultimately what will happen is this:
I would have expected this sequence:
The offending lines of code appear to be in bt_sequence.gd:
I can put in a PR for a fix, but I really don't have any good way to know if doing so would introduce issues elsewhere. When I see a slightly awkward construction like this, I have to think there is a reason for it.