Behavior Tree Decorator/Selector Only Runs the First Decorator

Ok… let’s take a step back and look at all of the variables and do some renaming.
“TrustRank” needs more specificity, because it’s a shared name in too many places.

Blackboard: This has the permanent variables. Name this one BB_TrustRank.

Decorator: This has variables that are kept within the decorator. You need three here: D_RankToCheck, which should be public and set outside because this is what you are checking against. Then KEEP your TrustRank variable but make it private- this should only be used to set the D_TrustRank value.

BBKey: Change this to also tell what value you’re trying to get. Name this one BBKey_TrustRank.

The Blackboard Key not retrieving anything, returning null- that means the BB_TrustRank is not set. You’re setting the TrustRank value on the Decorator- but because it’s named the same as the Blackboard value it’s getting confusing- those are not the same variable. The BBKey_TrustRank is pulling from here:

I have a good feeling this is not set:

Let’s just… Put the things where they need to go. Putting all of this on a decorator is not only confusing, it’s terribly non-performant nor reusable.

First: A BTTask:

This makes all of the checking and valuations have to run only ONCE as opposed to 5x so that’s a 5x improvement right there. This will set the trustrank as it needs to be set on the BB for checking.
Also you can reduce the amount of checks needed by removing the ceiling checks, if they don’t pass the floor checks, it’s the same thing so you’re just checking 2x more than needed. :slight_smile:

Next: A BTDecorator:


Decorators are typically this simple, however you can have a lot of checks going on but the main thing is to return TRUE/FALSE. Make sure you use “Perform Condition Check”!

Lastly: The BT/BB:

You run the task before asking which rank you’re looking for. :slight_smile:

This is your more typical use cases for these things and what I’m far more familiar with- not all of this is best practices, as the 6 options could be changed into a single task that checks the value and gets a certain value from a DataTable based on the trustrank.

Whew. Hope this helps with your thing! I couldn’t 1:1 as I don’t have everything you do but I figured going back and forth asking for one thing at a time was getting to be tedious.

Edit:
You don’t have to use a custom decorator. You can just use the built in “Blackboard” option:

1 Like