AAIController::UseBlackboard
#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
Bind blackboard then start behavior tree C++
void AMyAIController::OnPossess(APawn* InPawn)
{
Super::OnPossess(InPawn);
UBlackboardComponent* BBComp = nullptr;
if (UseBlackboard(MyBlackboardAsset, BBComp))
{
RunBehaviorTree(MyBehaviorTree);
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?