I need help to undestrand the behavior tree! I'm desperade

Hey! I had a little break from UE4 and now i started to learn again because i finally got my SSD! I was in middle of learning to understand behavior trees. Now i finally started to learn about how the BlackBoard keys actually works! There are still some of the things i don’t quite understand. I hope you guys can clear these up. Here is the first one:

The term “Observer”. What is that observer that we Notify? What does it mean when we notify it? And what does it actually mean when the Observer aborts on both? or if it aborts Lower priority or self? Can you expalin it in details, would help so much.

The big one i have been wondering alot: The “BlackBoard” screen we can use when we add decorators. I don’t really understand meaning of these. There is a value that we can change from “set” to “not set”. What is this Key Query? The bottom one of the blackboard is Set and the top one is set. Why it needs to be so? And again there is this Notify Observer system. Could somebody explain this to me in details? Thank you very much if somebody have time to answer.

Then i tried to make AI to wonder around when he is not aggroing. I could not get this to work. I’m not sure if i need to use the blackboard above selection. Could somebody expain what i need to do so that the AI would wonder around and then cancel it when he aggros and again returns to wonder if loose sight? The wondering works if i remove the the “isInRange” service but both of them wont work same time.

Here is the pic of it:

and here is what is inside the task. It just gets new position near self

I would really appreciade help so i can start to explore more.

I’m assuming you’ve already seen the BT documentation page.

For the first question on Notify Observer/Aborts, Unreal’s AI developer explains it in detail in this forum thread.

To summarize from that - notify observer allows your tree to react to changes in test conditions or test values (eg: bHasEnoughAmmo or targetActorIsSet) immediately as opposed to a synchronous flow control from node to node across the behavior tree where each condition will be evaluated only as flow passes from root to sub-node and so on. Aborts self/both/lower priority determine what happens when the tree detects a change in test condition.

In the example image you attached, ‘Aborts Both’ is used because the moment ‘TargetToFollow’ changes from either true to false or false to true, the branch currently executing needs to immediately abort and pass control over to the appropriate nodes, i.e again from your example - if the target to follow is suddenly lost then the AI needs to immediately abort looking for the player and fall back to the last observed position. On the other hand if the AI had lost track of the player and was regrouping to home location, the moment it sees the enemy it needs to immediately stop moving back to home and start chasing the player again.

To your second question - decorators are basically true/false conditions that you can construct in a separate blueprint for decision making. The ‘blackboard decorator’ is a just a handy pre-built decorator that encapsulates a basic value!=null to quickly check whether or not a particular key in the AI’s blackboard is set (or in the case of booleans true=set, false=not set).

I’m not entirely sure about the third question on why the wander to logic is not working - Maybe try refactoring the tree to run the service directly below the root with a selector below that connected to three sub-branches -

  1. “Is Wandering” (Aborts Self) pointing to the nodes to pick a random location and move to it,
  2. “IsTargetToFollow Set” (aborts both) with the closeenough/movetotarget, nodes and
  3. “IsTargetToFollow Not Set” with the fallback logic that eventually sets “is Wandering” back to true once the AI has reached the home location.

Hope that helps.

Thanks for this great information.