RealDocs

UBlackboardComponent::SetValueAsEnum

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

Description

Sets the raw enum value stored under the given blackboard key, notifying any registered observers if the value changed.

Caveats & Gotchas

  • Takes a raw uint8, not your enum type — cast your enum value explicitly, e.g. static_cast<uint8>(EMyState::Combat), or Blueprint's implicit byte conversion won't compile-check for you.
  • Silently does nothing if KeyName doesn't resolve to an enum-type key on the blackboard's data asset.
  • Setting an out-of-range value for the key's associated enum asset produces a meaningless read later — there is no bounds validation here.

Signature

void SetValueAsEnum(const FName& KeyName, uint8 EnumValue)

Parameters

Name Type Description Default
KeyName const FName& The name of the enum blackboard key to write.
EnumValue uint8 The raw enum value to store, cast to uint8.

Return Type

void

Example

Write a custom AI state enum C++
BlackboardComp->SetValueAsEnum(TEXT("AIState"), static_cast<uint8>(EAIState::Combat));

Tags

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.