UBlackboardComponent::GetValueAsFloat
#include "BehaviorTree/BlackboardComponent.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallable
Description
Returns the float value stored under the given blackboard key. Commonly used to read alert levels, distances, timers, and other scalar AI state.
Signature
float GetValueAsFloat(const FName& KeyName) const Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| KeyName | const FName& | The name of the float blackboard key to read. | — |
Return Type
float Caveats & Gotchas
- • Returns 0.0 silently for missing or wrong-type keys.
- • Key lookup is by FName, which is case-insensitive but typo-prone. Store key names in a const FName or use GetBlackboard()->GetKeyID() with the ID-based overload in performance-sensitive code.
- • If you need to distinguish between a missing key and a legitimately zero value, check HasKey() or GetValueAsEnum() separately — there is no 'unset' sentinel for float keys.
Example
Read an alert level from the blackboard C++
float Alert = BlackboardComp->GetValueAsFloat(TEXT("AlertLevel"));
if (Alert > 0.75f)
{
EnterCombatMode();
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?