UBlackboardComponent::SetValueAsVector
#include "BehaviorTree/BlackboardComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Writes an FVector to a blackboard key. Commonly used to store patrol points, last known enemy positions, or target locations so behavior tree tasks can read and act on them.
Signature
void SetValueAsVector(const FName& KeyName, FVector VectorValue) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| KeyName | const FName& | The name of the vector blackboard key to write. | — |
| VectorValue | FVector | The location to store. | — |
Return Type
void Caveats & Gotchas
- • Silently does nothing if the key doesn't exist in the BlackboardData asset.
- • Writing to a key declared with a different type in the BlackboardData asset is silently ignored.
- • The stored vector is a snapshot — it is not automatically updated if the source actor moves. Call SetValueAsVector again whenever the position changes, or use a SetValueAsObject key pointing to the actor instead.
Example
Store the last known enemy position C++
// When the AI loses sight of the player
FVector LastKnownPos = EnemyActor->GetActorLocation();
BlackboardComp->SetValueAsVector(TEXT("LastKnownPosition"), LastKnownPos); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?