UBlackboardComponent::SetValue
#include "BehaviorTree/BlackboardComponent.h"
Access: public
Description
Sets the value under the given key using the raw templated key-type API, notifying observers if the value actually changed. Returns false if the key doesn't exist or doesn't match TDataClass.
Caveats & Gotchas
- • TDataClass must match the key's actual UBlackboardKeyType subclass exactly, or the call fails and returns false without setting anything.
- • If the blackboard asset has synchronized (instance-synced) keys, setting one propagates the value to every other blackboard component sharing that asset and key.
- • For common types (bool, float, vector, object, etc.), the SetValueAsX wrappers (SetValueAsBool, SetValueAsVector, ...) are simpler and Blueprint-exposed — use this templated version mainly for custom key types.
Signature
template<class TDataClass> bool SetValue(const FName& KeyName, typename TDataClass::FDataType Value) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| KeyName | const FName& | Name of the blackboard key to set. | — |
| Value | typename TDataClass::FDataType | The new value to store, typed according to TDataClass. | — |
Return Type
bool Example
Set a value via the templated key-type API C++
BlackboardComp->SetValue<UBlackboardKeyType_Bool>(TEXT("IsAlerted"), true); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?