Can't connect or change the Blackboard Key with the connected Boolean variable.

Hello, I followed recently a tutorial by Ryan Laley on Youtube, where he created a Dialogue System with the Behavior Tree.

After I finished his tutorial series, I started his quest system series and tried my best to connect them, but I failed. I followed his quest system series until part 4, and I want to connect the two systems. If you talk to the NPC and then ask him if he needs help, the quest UI should open and react differently depending on my “answer”.

My Main Problem is with the Behavior Tree, because I can’t change the Boolean Condition when the Button is clicked. He can’t even enter a Boolean, who should be already true.
Here is a Google Drive Link, which lead to Screenshots, to understand my Situation better
https://drive.google.com/drive/folders/1g7yIicIxLv00xyb7FCEaoxEif5vuYV20?usp=sharing
Please, I really need your help. I’m stuck on that problem for several days.

You need to be a bit careful about setting blackboard variables so that you don’t accidentally Abort a condition higher up in the tree.

In your situation, you have 3 Booleans for “NotDecided”, “Accepted”, or “Rejected”. When the player makes their decision, you are (very reasonably) setting “NotDecided=False”. However, be careful about what your tree is saying here. It says it can only enter this sub-branch while “NotDecided=True”, so this whole subtree (including the Accept/Reject logic) will never run (is all unreachable) as soon as a decision is made.

You need to flatten this subtree so that the Accept/Reject logic is not a child of the “NotDecided” condition. Like so:

(Also, you might want to consider replacing those 3 Booleans with a single custom Enum. It would avoid the possibility of ever having bugs like accidentally have NotDecided and Accepted equal to True at the same time).

Hey, first of all thanks for that answer. I changed the Behavior Tree just like on your picture, but I still have this problem. Did I perhaps make a mistake when connecting to the Blackboard Key Selector? I also had the idea with the Enum and it is also good, but I am very bad with Enums.

I replaced those 3 booleans with a single custom enum, like you said, and it was much easier than I thought, the first part finally works :D, but when I press the button, the answer doesn’t change. I added 4 Images in the Google Drive Folder and named them with Enum. Could I check the enum at every tick, whether it has changed or not?

The new behavior tree set-up looks correct at first glance, so the issue possibly lies elsewhere in your code. Maybe the code that updates the Blackboard Enum is broken? Are you updating it in a Behavior Tree Service on your Root node? You might also want to use the AI debugging tools to hunt down the bug source (specifically the small sub-section on Behavior Tree):

One thing that is a bit weird to me in your new images is the new decorators (like “CheckIf_Not_Decided”). Are those custom-built Behavior Tree Decorators that you made yourself? Unreal’s built-in “Blackboard Based Condition” decorator already has support for checking if an Enum is a certain value, so it’s probably safer (bug-wise) to just use the built-in Decorator.

Also, Answerhub lets your embed images directly in your messages, so you don’t have to upload to Google Drive here :slight_smile:

The Reason why I made my own Decator was because of that:

I had a problem uploading an image in my first post, that’s why I uploaded to Google Drive, but it works now, so I’ll upload the images here. I think you’re right, my code for updating the blackboard enum is broken, because it doesn’t show the enums in the behaviour tree at all.

I changed my custom made decorators to the Unreal’s built-in “Blackboard Based Condition”. But I can’t find the mistake I made, I even tried to find a get node for “Get Blackboard”, but couldn’t find a suitable one. I found out, that my Log Messages, tell me that (The First Error is important, the below ones aren’t important to the problem):

I looked it up and if I’m right, it means that my Node Set value as Enum is empty, but if it’s because of the Get Blackboard Node, why can’t I find a suitable Get Node for it to make a reference?

Okay, I can’t post more pictures because it has reached the maximum for this post, so I upload them to the Google Drive folder. The new Images are “AI_Debugging_Enum…”, “Behavior Tree_5…” and “Enum_For_Quest_UI_Blackboard”.

Yeah, the first error is definitely a major problem. How are you assigning the proper Behavior Tree. Are your doing it the way Unreal’s official documentation shows? (Behavior Tree Overview | Unreal Engine Documentation)

https://docs.unrealengine.com/Images/Engine/ArtificialIntelligence/BehaviorTrees/BehaviorTreesOverview/BT_Overview_Anatomy_RunBT.webp

I noticed your are trying to get the blackboard (and set the enum) in the BeginPlay node of your custom AIController. However, usually this is the normal chain of events when the game begins:

  1. AI Character(Pawn) spawns (construction script runs)
  2. AI Character BeginPlay runs
  3. Some time passes (a few game ticks)…
  4. AI Controller Spawns (construction script runs)
  5. AI Controller BeginPlay runs
  6. Some time passes (a few game ticks)…
  7. AI Controller Possess Character (Pawn) <–This is usually where the Behavior tree is assigned to the controller

The problem is, you’re trying to set that enum on step 5, but getBlackboard is returning None because the blackboard is not even connected to the AIController until step 7. You should make sure you only try to access the Blackboard when you’re 100% sure that it is already set up an assigned (for example, you could do it after the Possess event in the Character class).

1 Like

In regards to the Blackboard Based Condition not allowing you to pick your custom Enum values from the drop-down: did you remember to set the proper Enum Type on the blackboard config page for your enum key? (Make certain Enum Type is not None)

In my current pictures on Google Drive you can see that I can pick up my custom enum values. I’ve fixed this before, but thanks. You mentioned that I should use the “Event On Possess” to run the behavior tree, but in the tutorial series I followed, he used a custom event instead, and when I try to use the “Event on Possess”, I can’t even start the dialog with the NPC. So I reconnected it to the custom event. Why can’t I change the enumeration value when I press the button? What am I doing wrong?