AAIController::ActorsPerceptionUpdated
#include "AIController.h"
Access: public
Specifiers: virtualAIMODULE_API
Description
Called by UAIPerceptionComponent when perception of one or more actors changes. Override to drive AI decisions based on newly sensed or lost targets.
Caveats & Gotchas
- • An actor appearing in UpdatedActors does not mean it was newly sensed — it may have had its stimulus age tick out. Query UAIPerceptionComponent::GetActorsPerception to get the full stimulus info and check WasSuccessfullySensed().
- • This is called on the game thread during the perception component's update tick. Avoid expensive operations here when many actors are being perceived simultaneously.
Signature
virtual void ActorsPerceptionUpdated(const TArray<AActor*>& UpdatedActors); Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| UpdatedActors | const TArray<AActor*>& | List of actors whose perception data changed since the last perception update tick. | — |
Return Type
void Example
React to newly perceived actors C++
void AMyAIController::ActorsPerceptionUpdated(const TArray<AActor*>& UpdatedActors)
{
for (AActor* Actor : UpdatedActors)
{
FActorPerceptionBlueprintInfo Info;
if (PerceptionComponent->GetActorsPerception(Actor, Info))
{
for (const FAIStimulus& Stimulus : Info.LastSensedStimuli)
{
if (Stimulus.WasSuccessfullySensed())
{
SetFocus(Actor);
break;
}
}
}
}
} See Also
Tags
Version History
Introduced in: 4.8
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?