UBlackboardComponent::SetValueAsInt
#include "BehaviorTree/BlackboardComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Sets the integer value stored under the given blackboard key, notifying any registered observers if the value changed.
Caveats & Gotchas
- • Silently does nothing if KeyName doesn't resolve to an int-type key on the blackboard's data asset — no error is logged.
- • Setting the same integer value again does not re-notify observers, since notifications only fire on an actual change.
- • Frequent writes from Tick can be expensive if many decorators observe the key, since each change triggers observer evaluation.
Signature
void SetValueAsInt(const FName& KeyName, int32 IntValue) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| KeyName | const FName& | The name of the int blackboard key to write. | — |
| IntValue | int32 | The integer value to store under the key. | — |
Return Type
void Example
Decrement an ammo counter C++
int32 Ammo = BlackboardComp->GetValueAsInt(TEXT("AmmoCount"));
BlackboardComp->SetValueAsInt(TEXT("AmmoCount"), Ammo - 1); See Also
Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?