UBlackboardComponent::GetValueAsEnum
#include "BehaviorTree/BlackboardComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns the raw enum value stored under the given blackboard key as a uint8. Used to read state machine-style AI state, such as a custom EAIState enum driving behavior tree branches.
Caveats & Gotchas
- • The return type is a raw uint8, not your enum type — you must cast it back to the correct enum yourself, e.g. static_cast<EMyState>(BlackboardComp->GetValueAsEnum(...)).
- • Returns 0 for a missing key or wrong-type key, which may silently alias a legitimate enum value of 0 — there's no distinct 'unset' sentinel.
- • The blackboard key's associated enum asset (set on the BlackboardData key) must match the enum you cast to, or the value will be meaningless.
Signature
uint8 GetValueAsEnum(const FName& KeyName) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| KeyName | const FName& | The name of the enum blackboard key to read. | — |
Return Type
uint8 Example
Read a custom AI state enum C++
EAIState CurrentState = static_cast<EAIState>(BlackboardComp->GetValueAsEnum(TEXT("AIState")));
if (CurrentState == EAIState::Combat)
{
EngageTarget();
} See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?