accessing blackboard key question

I have a boolean blackboard key, I set it to ‘true’ in my behavior tree task. Then I access it in AiController DIRECTLY and it’s showing as ‘false’.

proof I am using the correct blackboard in my tree
Capture


‘StartAnimBB’ is the key i’m talking about

task code that is setting the blackboard key to true, also included a string to check if it’s true.

proof that the blackboard key has been set to true
Capture4
The branch node will NOT execute unless that value was true = exiting the task. so yes, it IS true.

proof that I am accessing that same exact blackboard AND blackboard key from my ai controller

I only have one blackboard! and after all this and it’s still false! what’s going on here? I’ve been stuck for 4 days now, please only answer if you can provide confident answers.

Thank you for your replies

Hi @str4w_b3rrieZ, I think I know a solution, but I have a question about your ai system which might explain this issue.

  1. Where are you running the behavior tree? As in did you use the RunBehavior in your ai blueprint or your controller?

I think the solution I’m talking about might not matter, but I wanted to ask anyways. Thanks for your time!

How do you know? Is “SelfActor” the same actor in both cases? Print its value both when setting and when reading. Print the blackboard path/display/instance name, too.

One of two things are happening:

  1. You’re setting the boolean on a different instance of the same blackboard class than what you read from
  2. The value gets cleared by some other code path before you read it

My guess is it’s #1, perhaps PlaySeqFromBT is not the same object as AIController_Spawner?

1 Like

this is important, the behavior tree is running WITHIN a component inside my character BP
Capture1

the content of the components tell it exactly which tree and blackboard to use:


note: this is not the full tree, I’m showing you the important part only.

within the ai controller it’s making reference to that same EXACT blackboard

this ai controller is attached to the character

to answer your question it is being run within my character blueprint inside a component and yes, this code is working, I just can’t access the blackboard key.

Hello, thank you for your reply, yes you are correct, I did some testing and found:

aicontroller_spawner is not the right aicontroller, I put a string to view the ai_controller name and it’s Dialogue_ai_controller3


Capture2

so I changed the ai_controller in my character BP and ran this code in Dialogue_AI_controller to check it’s value

it starts off as false, as it should.

when the key is set to true it does this weird thing where it’s set but also says it’s not set?


I have circled where it says it’s been set

So while the blackboard key is true, it doesn’t set the variable inside Dialogue_Ai_Controller to true. Here is the task that sets the blackboard key


does this look okay? I don’t really know whats happening here so I really need help.

It’s probably the case that you have multiple object instances.
This happens when you spawn multiple objects, OR when you’re doing networked game development.

1 Like

That’s not what the code you’re circling does.
It makes a reference to the same blackboard CLASS but not the same blackboard INSTANCE.

When a behavior tree is executed, it creates a new instance of the blackboard.

Hello, thank you for your reply.

Sorry I am a beginner and I did not know this, thanks for letting me know. So if I understand correctly you are saying I am not accessing the blackboard key correctly? can you let me know how I could get that same instance of the blackboard I want? I never heard about this and I can’t find any help on it unfortunately.

You let the AIController create the blackboard (typically from the behavior tree.)
Then you use “get blackboard” in all the other components.
The “get blackboard” Blueprint function takes either a Pawn or an AIController object, and will find the corresponding blackboard component from the AIController.

Hello, thank you for you reply once again.

I wanted to check if I’ve understood everything you have said so far correctly. Right now my component that contains my ai controller and behavior tree can be assigned to many different actors on my level. In my level there are about 3 altogether using it which creates multiple instances, as you said. So therefore I cannot access a specific blackboard key because it is creating 3 different blackboard instances so therefore I cannot exactly access it directly because it’s not possible.

is this correct?

I apologize for bothering you once again please know I appreciate your help with this issue.

A blackboard key is typically “in context of the particular actor that’s being controlled.”
Just because one actor has seen the player, doesn’t mean that all actors have seen the player.

However, there’s actually a way to get the blackboard to behave like you say – if any one actor changes the value, everyone sees that change. This frequently leads to hard-to-control behavior, but if there’s some global state like “the base is on lockdown alert” that you need, it’s a convenient way to model that.

To get that behavior for a particular key, check the “Instance Synced” property for the key in question:

1 Like

i think im gonna cry…

I saw this option many times but I had no idea what it meant, if only i clicked it earlier :sob:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.