RealDocs

AAIController::UseBlackboard

function AIModule Blueprint Since 4.0
#include "AIController.h"
Access: public Specifiers: UFUNCTIONBlueprintCallable

Description

Binds a Blackboard data asset to this controller, creating a UBlackboardComponent if one does not already exist. Returns true on success.

Caveats & Gotchas

  • If a UBlackboardComponent already exists and its asset is compatible (same parent hierarchy), the existing component is reused and the function returns true without resetting key values — preexisting key data is preserved across calls.
  • When called from C++, the BlackboardComponent out-parameter is populated even if the function returns false; always check the return value before using it.
  • Must be called server-side (or in a non-networked context); the Blackboard is not automatically replicated, so clients reading blackboard keys need a separate replication scheme.

Signature

bool UseBlackboard(UBlackboardData* BlackboardAsset, UBlackboardComponent*& BlackboardComponent)

Parameters

Name Type Description Default
BlackboardAsset UBlackboardData* The Blackboard data asset to bind.
BlackboardComponent UBlackboardComponent*& Output reference set to the Blackboard component that was created or reused.

Return Type

bool

Examples

Initialize the blackboard then start the behavior tree on BeginPlay Blueprint
Event BeginPlay Cast To AAIController Object Cast Failed As AI Controller As AI Controller Use Blackboard Target is AI Controller Target Blackboard Asset Return Value Blackboard Component Blackboard Component Branch Condition Condition True False Run Behavior Tree Target is AI Controller Target BT Asset Return Value Get Controller Target is Pawn Return Value Return Value
Edit Blueprint graph Initialize the blackboard then start the behavior tree on BeginPlay
Drag node headers to move · Drag from an output pin to an input pin to connect · Scroll to zoom · Right-click for actions
Bind blackboard then start behavior tree C++
void AMyAIController::OnPossess(APawn* InPawn)
{
	Super::OnPossess(InPawn);

	UBlackboardComponent* BBComp = nullptr;
	if (UseBlackboard(MyBlackboardAsset, BBComp))
	{
		RunBehaviorTree(MyBehaviorTree);
	}
}

Version History

Introduced in: 4.0

Version Status Notes
5.6 stable

Feedback

Was this helpful?

Suggest an edit

Select a field above to begin editing.