Blackboard Documentation

How to Get and Set Blackboard Entries

In a Behavior Tree Node blueprint:
Use the Get… and/or SetBlackboardValueAs…() node for the appropriate type. This node doesn’t require the blackboard, as it will fetch it from the owning behavior tree.

Create a variable of type BlackboardKeySelector and use that to feed into the “Key” node.

Check the “Editable” box in the details on this variable (or just click the “eye” icon to open it). That will expose the value of the blackboard key to the node in the behavior tree on any node created from your blueprint, so you can point it to the correct blackboard entry using a drop-down.

(I’ll come back and add a screenshot here soon.)

For clarity and completeness, here are the specific Getter and Setter nodes we have for each type of blackboard entry:

  • GetBlackboardValueAsBool, SetBlackboardValueAsBool

  • GetBlackboardValueAsInt, SetBlackboardValueAsInt

  • GetBlackboardValueAsFloat, SetBlackboardValueAsFloat

  • GetBlackboardValueAsVector, SetBlackboardValueAsVector

  • GetBlackboardValueAsEnum, SetBlackboardValueAsEnum

  • *]NOTE: This function is used to get and set both “Enum” and “NativeEnum” types.

  • GetBlackboardValueAsString, SetBlackboardValueAsString

  • GetBlackboardValueAsName, SetBlackboardValueAsName

  • GetBlackboardValueAsActor, SetBlackboardValueAsActor

  • *]NOTE: This function is provided for convenience. It’s basically the same as the “AsObject” version, but it casts the result to AActor as well (since not all Objects are Actors, it can return NULL for Getting a value if it’s there but is not an Actor).

  • GetBlackboardValueAsObject, SetBlackboardValueAsObject

  • GetBlackboardValuesAsClass, SetBlackboardValuesAsClass

In any other blueprint (not part of a behavior tree):

Get the blackboard you intend to access values on (for example, in Behavior Trees you can use GetBlackboard() node if you choose not to use the Behavior Tree accessors above). (But you should probably be using the Behavior Tree accessors instead.)
Dragging off of the Blackboard, you can create GetValueAs… / SetValueAs… functions for the appropriate types.
Pass in the FName of the key you are attempting to access. This value needs to match the Entry Name property in the Blackboard asset.

Again, I’ll add a screenshot here soon.

And here are the specific getters and setters for various blackboard entry types:

  • GetValueAsBool, SetValueAsBool

  • GetValueAsInt, SetValueAsInt

  • GetValueAsFloat, SetValueAsFloat

  • GetValueAsVector, SetValueAsVector

  • GetValueAsEnum, SetValueAsEnum

  • *]NOTE: This function is used to get and set both “Enum” and “NativeEnum” types.

  • GetValueAsString, SetValueAsString

  • GetValueAsName, SetValueAsName

  • GetValueAsObject, SetValueAsObject

  • *]NOTE: There are no pre-written specializations for these. If you need a specific class such as AActor or APawn (or even a blueprint class), you need to use “Cast To” on the results from this node, and then you should determine if it returned TRUE/FALSE appropriately.

  • GetValuesAsClass, SetValuesAsClass

Some additional helpful blueprint nodes for blackboard access:

  • ClearValueAsVector: Sets the Vector value back to “invalid”, which is a vector of MAX_FLT. This basically makes the vector “unset” again, by making it match the normal “uninitialized” values of these vectors.
  • GetLocationFromEntry: Gets the location vector from any valid key type. Basically, if the key is a Vector, it will return that value. If it’s an Actor, it will return GetActorLocation() from that Actor.
  • GetRotationFromEntry: Returns the rotation of the entry if it can. Specifically, if the entry is pointing to an Actor, it calls GetActorRotation() on that actor.

Getting and Setting Values in C++:
See UBlackboardComponent in BlackboardComponent.h to find the many functions you can use.

Basically, you can call of the GetValueAs/SetValueAs functions I mentioned above for general blueprint use, but you can call them with either the Entry Name as an FName or the uint8 ID of the entry

In addition, a few functions to note are:

  • GetKeyName(uint8 KeyID) fetches the name from the ID.

  • GetKeyID(const FName& KeyName) getches the uint8 ID from the name (which you can use for caching if you like).

  • GetKeyType(uint8 KeyID) returns the class of value for the specified key.

  • You can also call the same helpful blueprint nodes I mentioned above from code:

  • *]ClearValueAsVector (taking KeyName or KeyID)

  • *]GetLocationFromEntry

  • *]GetRotationFromEntry