Hard time with BlackBoard Key Selector

Hey there! I’m having nightmares with the Blackboard Key Selector right now. I’m trying to set up an AI behavior tree for one of my characters.

Since I plan to have multiple mechanics for this character, I’m using an Enum that lists all the possible states the character can enter.

This Enum is used as a key named “CurrentState” in my blackboard (so it can retrieve all the states from the Enum list).

Now, I need to initialize my Behavior Tree and Blackboard in my BP_AIController, but I can’t find a way to properly reference the correct Blackboard Key Selector in the “Key Name” input of the “Set Value as Object” node.

For reference, I have two Blackboard Key Selectors to set up:

  • TargetActor (Object, Character) – The character the AI should be following.
  • CurrentState (Enum “E_EcoState”) – The current state the character should be in.

I can’t figure out how to “plug” these Key Selectors into the node.

Maybe I’m doing something completely wrong, but I’m totally lost right now!

Thanks for your time and help!

Alex

Use enum directly inside of your blackboard (Extend with key type dropdown)

Narrow down your keys in blackboards to a more precise class (exact enum, actor, etc) it will make your life easier when dealing with ai.

Also when reading the variable from your blackboard make sure to convert to your target enum or you will get an integer

In this example I switched to the second enum value attacking

And as you see it carries over to the scene

image

Default enum value in the blackboard would be the first element “Patrolling”

If I skip the set

I get

image

Also you pass in the name of the key through a literal variable => pull of the key name and type in literal (If i remember correctly it’s probably a literal name variable)

“make literal name”

Thanks for you help everyone !!! Everything works amazing now

1 Like