Behavior Tree Decorator/Selector Only Runs the First Decorator

Hi! I really need some help with my behavior tree. I’ve done some troubleshooting and it seems as if my selector/decorator only ever runs the first option, even if the data isn’t valid. For example: my game has relationship ranks, so if a character has relationship rank 4, the character should say “you are my friend.” But instead, it always does the result for relationship rank 0 “I HATE YOU!” (I’m in the testing phase, okay…) But if I switch whichever one is run first, it’ll go to that rank. By all accounts, I do believe it should display the right message.
Here’s a video showing everything you need to see:

Thank you so much for your time, I would appreciate help so much!

1 Like

Hey @Maximum.Dino!

When you’re setting the blackboard value, do you have the key labeled EXACTLY the same? No extra spaces, etc? Can you show us that?

Thanks! :slight_smile:

1 Like

Here’s what my Blackboard keys look like and all-

What does the key need to match exactly with? I’m not sure, is my BBData supposed to be called “Trust Rank”? My apologies, I’m new to blackboards and BTs

Well something to keep in mind is that a decorator is just a big fancy Bool check.

It’s always returning “True” because you’re checking the output string against itself, which will always return true. There’s no chance for it to be false.

I think here you should regroup. Take allllll of this and put it in a task, to be run one time before this selector as part of a sequence. So sequence: 1run this task, 2selector you have here.

Then have decorators on each of these ONLY CHECKING: Is TrustRank == 0/1/2/3/4/5

1 Like

I’ll try putting them into a task! I actually think that part of my issue was fixed, now it doesn’t call them all as true, but it calls them all as false now- except for trust rank 0, which is called correctly, but all the others, despite having the same code, always come out false. It’s quite strange, it looks like the BBData key int is always 0 even though I’ve tried connecting it to the trust rank key. The problem lies in the fact that the BBData key only ever equals 0- do you have any idea how to fully get it to connect to the trust rank number that I list in the decorator on the tree?
Once again thank you so much!

Sure do!

Select the variable on the left hand side of BBData and then in your details window on the right it will allow a string input- this needs to match the name of the variable you want to alter EXACTLY, and the type going in must be of the same variable type as the one you’re trying to set (for instance if you need to convert an integer to a string, do so first). :slight_smile:

Is the string input the name of the variable? So in this case, would I want to name it TrustRank? I am a little confused still on what variables need to match, because I’ve tried to match them before. Thank you!

So the key has it’s own name, in this case BBData.
But that’s just the label of the key. The string CONTAINED within the key will determine which BB variable will be linked up to it. So if you’re trying to change “TrustRank” to match “Output”, you open the BBData Key and set the key value to be TrustRank (exact capitalization and spaces). Also make sure if TrustRank and Output are the SAME KIND of variable (int, float, string, etc)

1 Like

I don’t have the option to open the BBData key and set the key value, I guess that’s what’s confusing to me. Here’s the details panel for the BBData key and information on the trustrank key type

So I was misunderstanding, you set the key outside of this on the Behavior Tree per decorator.

I am very much believing that the problem is you are trying to set a value using a decorator- that’s explicitly what a task would be used for, and if it needed to be constantly updated that is what a service would be for. I have never tried setting a value using a decorator, but the idea is that if it were possible what would be the use of a service/task? The only thing I have ever known decorators to be used for is reading.

Also the icon for it is a cube which is the symbol for a data-only blueprint, which is not used to set data elsewhere. That might be the problem. Data only blueprints can process and return values but cannot set them outside of the blueprint.

1 Like

To my understanding, I’m not trying to set a value using the decorator, I’m trying to check the value, if that makes sense.
I’m not sure where exactly to set the trust rank if I’ve already set the BBData to be exactly the TrustRank, which is identical to the blackboard trustrank key (like this)

I have a working choice system that is very similar and used that as reference to create this. The choice system checks a string identical to the choice chosen, and the decorator decides if it’s true or false. That was the goal of this decorator, too, except it checks the trust rank instead of the choice chosen.
So sorry it took so long to respond, thank you for being patient with me.

Ah, but you ARE trying to set a value on the blackboard using the decorator- whether that’s what you’re wanting or not!
image
That’s what this node does. It’s attempting to set a value on the blackboard attached to the BT that houses this decorator. So this needs to be removed (the SET blackboard value as string).

My mind says if these are going to just be numbers they should be an Integer variable… but I don’t think that matters as long as they match, I’d keep them as strings unless you really run out of options.

As I was worried about earlier, it’s possible I’m wrong and you CAN set variables through decorators.

In that case, it’s just that your logic is automatically causing true response. Because you’re taking the value you want to check against(trustRank) and you’re setting it to BE the value you want to check FOR (output). So if you’re changing trustRank to = Output, it will always return true when you ask IS trustRank === Output.

1 Like

I don’t know when I removed it, but I removed that node a little while ago. Now the trustrank value is correct, but it only goes through for the first decorator. If the trust rank is 0, it works. If it isn’t, it loops to the beginning of the tree entirely. Here’s an updated look at what I have

Okay! It sounds like we’re on the right track!

You didn’t by chance switch out your Selector for a Sequence on the behavior tree, did you?

Unless the DEC_CheckData is supposed to be connected to a selector, no. I used the sequence node because it was what was used in the choice system I have that works, but I could be wrong

Have you tried the debug window?

You can have the behavior tree up in another window and when you run the game, use shift+f1 to get your cursor back and open it up. At the top rightish there will be a dropdown to select a character to monitor. Then you can activate it, pause it, and step through step by step. It may be going through all of them instead of restarting.

This is really important for using Behavior Trees so get acquainted with doing this!

Also above the cutoff of the behavior tree, is that a selector, a sequence, what are we working with?

1 Like


This video shows off what’s actively going on in the behavior tree, and it looks like, if the trust rank isn’t 0, it returns to the previous tree (which has just basic dialogue on it). The print string is telling me what if the trust rank equals the one on each branch, and it says they’re all false except for trust rank 0. It looks as if it’s skipping through them, but it could be going to fast for me to tell.

In addition, when I put up the debug menu, this is all it does. I’m not sure if there’s a specific actor I should be clicking, but the behavior tree is mostly tied to the UI. I don’t see the dropdown you speak of either, sorry

You had it! :slight_smile:

It’s the >> next to these buttons here.

So if you Open up the interaction UI and get the BT started, then PAUSE the simulation (use Play In Editor for ease of use) you can use these buttons to go one step at a time to prevent it from going too fast. It’s very likely that’s what is happening.

The first one is working perfectly, at least. It’s supposed to skip over.

Your decorators are set to 0,1,2,3,4 etc I assume? If so, we need to check why it’s returning false, possibly within the code to set the output?
image

1 Like


This is where I set trust rank-

And this is where I make sure they’re equivalent

And here’s what the tree is looking like using the debug and back-forth tools

A couple of things I’m noticing:

This trustrank string within the decorator is being set to null:
image

And the bbkey to string is printing null as well, no number is being printed:

Meaning on the first output it will return true as null=null, since it’s not 0 (which technically is a value).

Therefore, the problem lays specifically around the Key and it not giving what you need.
Try printing the BBData key, just plug it into a print node and it’ll convert, let’s see what it’s returning as its name!

1 Like