Hey all, I’ve encountered an issue with Behavior Trees that unless I am misunderstanding something may potentially be a bug. I have an AI that moves towards the player while a service runs and checks if the distance between the AI and the player is within a range. If it is, the blackboard key “withinRange” is set to true.
I have placed a decorator on the move function and have set to observe “On Value Change”(also have tried Result Change.) What I expect to happen, is that when the blackboard key changes, the condition fails and aborts the task.
What is actually happening is that the decorator does not observe the change to the blackboard key until execution has finished.
Am I misunderstanding how things should work, or is this an engine bug? Help would be appreciated! This is driving me up the wall. In the meantime of awaiting a response, I am going to try to just implement an observer in my custom task that will finish the task upon value being changed.
I usually set it up like you did in the “Attack” side. Have you tried having a sequence with only the decorator on the movement side, then using “aborts both”? Also, try using the “Step” tool in the play menu above to go step by step, it’s possible that it is looping back around and it just looks like it’s staying on the left.
This would never fire already since movement is still in progress, having value changed (if in charge) will trigger conditions for execution/abort , it doesn’t detect change if not in charge.
So logically you have to re organise what you are doing.
Selector
Sequence (Attack)
Decorator (CurrentDistance<AttackRange)(Aborts)
Task Attack
Sequence (Chase)
Decorator (WithInAttackRange) (Aborts)
Task MoveTo
Delay (0.2)
So AI starts move, checks can attack : no-> Starts chase cause not in range
Start the move (you can add here service to abort again if you like immidiate)
If not cancelled wait 0.2 → starts chase again since player moved to another location (if you have repathing it won’t do it which is better)
Starts the move → cancels after 2 seconds since your service said within range and cancelled.
All selector starts again, check Attack → bool valid
Task Attack → Task Attack-> Task Attack
Something like this should help , you don’t need many service and decorators