RealDocs

UBlackboardComponent::InitializeBlackboard

function AIModule Since 4.0
#include "BehaviorTree/BlackboardComponent.h"
Access: public

Description

Sets up the component to use the given blackboard data asset, allocating value storage for its keys. Returns true if initialization succeeded.

Caveats & Gotchas

  • Call IsCompatibleWith first if you're swapping assets at runtime; passing an incompatible asset (one that isn't the same as, or a child of, the currently used asset) can fail or produce mismatched key IDs.
  • This is how AAIController::UseBlackboard ends up assigning the asset — most gameplay code should go through UseBlackboard rather than calling this directly.
  • Existing key values and observers are discarded when a new asset is initialized.

Signature

bool InitializeBlackboard(UBlackboardData& NewAsset)

Parameters

Name Type Description Default
NewAsset UBlackboardData& The blackboard data asset to initialize this component with.

Return Type

bool

Example

Manually initialize a blackboard component C++
UBlackboardComponent* BB = NewObject<UBlackboardComponent>(this);
if (BB->InitializeBlackboard(*MyBlackboardDataAsset))
{
    BB->SetValueAsBool(TEXT("IsAlerted"), false);
}

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.