How to use the behavior tree

I’m trying to get my head around how the decorators work and how the different rules actually work.

So I got this setup right now


Three differnt orders which each has a specific Integer linked to them. In the picture we se order 3 (left) and 2(right).
This integer is set in the blackboard of the Actor.

So with this BT setup I would expect the AI to execute the right branch if I issue order 2 to the AI? Aborting itself and everything in that branch in case I would give the order 3, and instead starting to execute the left branch?
Is this correct?

Also, what does “Lower priority” mean. Would The branch on the right be lower priority than the one on the left?

Becasue I rarely see the behavior from the tree that I would expect when I add different decorators. It just seem to execute in any way it wants.
In this example, when I actually give order 1 or 3 it just keep on going down the Order 3 branch. And yes the Order blackbaord value is set correctly.

Here, the selector node will run from left to right, running your BB condition nodes until once succeeds, then it will run that sub-tree.

You aren’t giving an order through your BB.

Yes, but wouldn’t the leftmost branch run if the CurrentOrder blackboard value would be set to 3?

And wouldn’t the right branch fail unless the CurrentOrder value is set to 2?

This is the full tree running


CurrentOrder is Currently 0

And here CurrentOrder is 3

This doesn’t match the expected flow I’d expect from the setup I have. So cleraly I’m doing something wrong… but what?

To be clear, this is the left branch?

It will always run the left first. But it will move to the middle, if the condition is not met:

This is correct. Current order is 3.

It can’t go down first branch, because it must be <> 3

Middle branch condition is <> 2. 3 <> 2, so we go down the middle.

That is the left branch yes.

And as I start CurrentOrder is set to 0.
So in my mind all of the branches would fail and the BT would go to the Wait node at the top.

I then Issue order 3 with some blueprint script and the BB value CurrentOrder is changed to 3.
Wouldn’t that mean that the left brnach would then be valid and actually run?

Wah?..

0 <> 3, so it goes does the left :slight_smile:

Hold on, sorry, maybe I have it inverted… No, I checked one of mine.

The node has to evaluate to true. 0 <> 3, go down left branch.

It aborts if the condition is not met, ie, CurrentOrder = 3

So this would be more correct in the case of the left branch?
image

Yes, now it goes down there if CurrentOrder = 3, otherwise aborts…

Ah yes!
Totally got confused there, expected it to fail unless it was 3.

Cheers!

1 Like