RealDocs

UBlackboardComponent::SetValueAsFloat

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

Description

Writes a float value to a blackboard key, which can then be read by behavior tree tasks and decorators. Commonly used to store alert levels, distances, counters, and other scalar AI state.

Signature

void SetValueAsFloat(const FName& KeyName, float FloatValue)

Parameters

Name Type Description Default
KeyName const FName& The name of the float blackboard key to write.
FloatValue float The value to store.

Return Type

void

Caveats & Gotchas

  • Silently does nothing if the key doesn't exist in the BlackboardData asset.
  • Writing a float to a key declared with a different type in the BlackboardData asset is silently ignored. Type mismatches are not logged in non-debug builds.
  • Changes are visible to behavior tree nodes immediately — if a decorator is observing this key, the tree may be interrupted and re-evaluated on the next tick after the write.

Example

Update an alert level C++
// In an AI perception handler
BlackboardComp->SetValueAsFloat(TEXT("AlertLevel"), NewAlertLevel);

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.