RealDocs

UBlackboardComponent::GetValueAsInt

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

Description

Returns the integer value stored under the given blackboard key. Commonly used for counters, ammo totals, or squad size tracked as AI state.

Caveats & Gotchas

  • Returns 0 silently for a missing key, wrong-type key, or an unset key — there is no distinct 'unset' sentinel.
  • Key lookup is by FName every call; cache the key ID with GetKeyID() and use the ID-based template accessor in performance-sensitive loops.
  • If the blackboard key was authored as a different numeric type (e.g. Float) in the BlackboardData asset, this returns 0 rather than converting.

Signature

int32 GetValueAsInt(const FName& KeyName) const

Parameters

Name Type Description Default
KeyName const FName& The name of the int blackboard key to read.

Return Type

int32

Example

Read an ammo count from the blackboard C++
int32 Ammo = BlackboardComp->GetValueAsInt(TEXT("AmmoCount"));
if (Ammo <= 0)
{
    BlackboardComp->SetValueAsBool(TEXT("NeedsReload"), true);
}

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.