AAIController::GetBlackboardComponent
#include "AIController.h"
Access: public
Specifiers: const
Description
Returns the Blackboard component associated with this controller, or null if UseBlackboard has not been called. Two overloads exist: a const version and a non-const version that allows key writes.
Caveats & Gotchas
- • The const overload returns a const pointer; use the non-const overload (UBlackboardComponent* GetBlackboardComponent()) when you need to set key values.
- • If RunBehaviorTree is called without a prior UseBlackboard call, the BT will start but any task reading a key will find the component null and likely assert at runtime — always call UseBlackboard first.
Signature
const UBlackboardComponent* GetBlackboardComponent() const Return Type
const UBlackboardComponent* Example
Read a blackboard key value C++
if (const UBlackboardComponent* BB = GetBlackboardComponent())
{
AActor* Target = Cast<AActor>(BB->GetValueAsObject(TEXT("TargetActor")));
if (Target)
{
// Target is valid, proceed
}
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?