Navigation
API > API/Runtime > API/Runtime/AIModule
A helper type that improved performance of reading data from BB It's meant for a specific use-case: 1. you have a logical property you want to use both in C++ code as well as being reflected in the BB
- you only ever set this property in native code
If those two are true then add a member variable of type FBlackboardCachedAccessor like so:
FBlackboardCachedAccessor
and from this point on whenever you set or read the value use this variable. This will make reading almost free.
Before you use the variable you need to initialize it with appropriate BB asset. This is best done in AAIController::InitializeBlackboard override, like so:
const FBlackboard::FKey EnemyInMeleeRangeKey = BlackboardAsset.GetKeyID(TEXT("EnemyInMeleeRange"));
BBEnemyInMeleeRangeKey = FBlackboardCachedAccessor
Best used with numerical and boolean types. No guarantees made when using pointer types.
does not automatically support BB component or asset change
| Name | FBBKeyCachedAccessor |
| Type | struct |
| Header File | /Engine/Source/Runtime/AIModule/Classes/BehaviorTree/BlackboardComponent.h |
| Include Path | #include "BehaviorTree/BlackboardComponent.h" |
Syntax
template<typename TBlackboardKey>
struct FBBKeyCachedAccessor
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| BehaviorTree/BlackboardComponent.h | |||
FBBKeyCachedAccessor
(
const UBlackboardComponent& BBComponent, |
BehaviorTree/BlackboardComponent.h |
Typedefs
| Name | Type | Remarks | Include Path |
|---|---|---|---|
| FStoredType | TBlackboardKey::FDataType | BehaviorTree/BlackboardComponent.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| BBKey | FBlackboard::FKey | BehaviorTree/BlackboardComponent.h | ||
| CachedValue | FStoredType | BehaviorTree/BlackboardComponent.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
const FStoredType & Get () |
BehaviorTree/BlackboardComponent.h | ||
T2 Get () |
BehaviorTree/BlackboardComponent.h | ||
bool IsValid() |
BehaviorTree/BlackboardComponent.h | ||
bool SetValue
(
UBlackboardComponent& BBComponent, |
BehaviorTree/BlackboardComponent.h | ||
bool SetValue
(
UBlackboardComponent& BBComponent, |
BehaviorTree/BlackboardComponent.h |