BT
MemoryDecay - use
FActorPerceptionInfo::GetLastStimulusLocation(&OutAge)
TL;DR: Unreal Engine's
UAIPerceptionComponent already tracks per-actor last-known
stimulus location with age. No need to roll your own decay timer.
Pattern (in your AIController or a small custom service)
UAIPerceptionComponent* Perception = GetAIPerceptionComponent();
if (!Perception) return;
// Pull the last-known info for a specific actor (e.g. the threat you're tracking).
if (const FActorPerceptionInfo* Info = Perception->GetActorInfo(*ThreatActor))
{
float Age = 0.0f;
FVector LastKnown = Info->GetLastStimulusLocation(&Age);
// Apply your project's memory window.
if (Age < MemoryWindowSec)
{
Blackboard->SetValueAsVector("LastKnownThreatLoc", LastKnown);
Blackboard->SetValueAsFloat ("MemoryAge", Age);
Blackboard->SetValueAsBool ("bHasMemory", true);
}
else
{
// Memory expired.
Blackboard->SetValueAsBool("bHasMemory", false);
}
}
That's it. Perception's age tracking handles refresh-on-stimulus + decay automatically.
How to integrate as a BT service
Wrap the snippet above in a UBTService_BlueprintBase
subclass (Blueprint-only - no C++ needed):
- Create a BP service. Override
Receive Tick. - Inputs:
ThreatActor(Object BB key) +MemoryWindowSec(float). - Inputs to write:
LastKnownThreatLoc(Vector BB key) +MemoryAge(Float BB key) +bHasMemory(Bool BB key). - Tick body: get perception component →
GetActorInfo→GetLastStimulusLocation(&Age)→ branch on Age vs window → write BB keys.
Five nodes total. No C++ required.
Why we didn't ship
LCM_BTService_MemoryDecay
The stock
FActorPerceptionInfo::GetLastStimulusLocation(&OutAge)
provides everything our planned MemoryDecay service would - location +
age tracked per sense, per actor, automatically
refreshed on stimulus and aged each frame.
Rolling our own decay timer would:
- Duplicate the perception component's bookkeeping
- Miss the per-sense granularity (perception tracks separately for Sight / Hearing / Damage / etc.)
- Force buyers to maintain two parallel "last seen" caches
The LCM Nav3D StateTree variant FLcmSTEval_Memory. Same
conclusion on both sides.
Related LCM Nav3D-unique services
If you want squad-level memory (where multiple
allies' perceived-actor lists are aggregated), use
LCM_BTService_SquadSnapshot - that's a genuinely LCM
Nav3D-additive surface.