UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
FBBKeyCachedAccessor< TBlackboardKey > Struct Template Reference

#include <BlackboardComponent.h>

Public Member Functions

 FBBKeyCachedAccessor ()
 
 FBBKeyCachedAccessor (const UBlackboardComponent &BBComponent, FBlackboard::FKey InBBKey)
 
template<typename T2 >
bool SetValue (UBlackboardComponent &BBComponent, const T2 InValue)
 
bool SetValue (UBlackboardComponent &BBComponent, const FStoredType InValue)
 
const FStoredType & Get () const
 
template<typename T2 >
T2 Get () const
 
bool IsValid () const
 

Detailed Description

template<typename TBlackboardKey>
struct FBBKeyCachedAccessor< TBlackboardKey >

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
2.  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<UBlackboardKeyType_Bool> BBEnemyInMeleeRangeKey;

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<UBlackboardKeyType_Bool>(BlackboardComp, EnemyInMeleeRangeKey);

Best used with numerical and boolean types. No guarantees made when using pointer types.
Note
does not automatically support BB component or asset change

Constructor & Destructor Documentation

◆ FBBKeyCachedAccessor() [1/2]

◆ FBBKeyCachedAccessor() [2/2]

FBBKeyCachedAccessor< TBlackboardKey >::FBBKeyCachedAccessor ( const UBlackboardComponent &  BBComponent,
FBlackboard::FKey  InBBKey 
)
inline

Member Function Documentation

◆ Get() [1/2]

const FStoredType & FBBKeyCachedAccessor< TBlackboardKey >::Get ( ) const
inline

◆ Get() [2/2]

template<typename T2 >
T2 FBBKeyCachedAccessor< TBlackboardKey >::Get ( ) const
inline

◆ IsValid()

bool FBBKeyCachedAccessor< TBlackboardKey >::IsValid ( ) const
inline

◆ SetValue() [1/2]

bool FBBKeyCachedAccessor< TBlackboardKey >::SetValue ( UBlackboardComponent &  BBComponent,
const FStoredType  InValue 
)
inline
Returns
True is value has changed

◆ SetValue() [2/2]

template<typename T2 >
bool FBBKeyCachedAccessor< TBlackboardKey >::SetValue ( UBlackboardComponent &  BBComponent,
const T2  InValue 
)
inline

The documentation for this struct was generated from the following file: