Quick answer: Add an AIPerceptionStimuliSourceComponent to detected actors and call RegisterForSense(UAISense_Sight::StaticClass()). The AI’s AIPerceptionComponent needs a matching Sense Config with the right affiliation flags.
Here is how to fix Unreal AI Perception failing to detect actors that should be in line of sight. Detection requires both perception and stimulus source registration; either side missing means no detection.
The Symptom
AI character has Sight sense configured. Player walks into view; OnPerceptionUpdated never fires. AI does not react.
What Causes This
No stimulus source. Perceived actors need to register as a stimulus source for each sense.
Affiliation mismatch. Sight Config has Detect Enemies / Neutrals / Friendlies flags. If none of these match the player’s team, no detection.
Sight radius too small. Default sight radius may not cover the player.
The Fix
Step 1: Add stimulus source on the player.
// In APlayerCharacter constructor
StimuliSource = CreateDefaultSubobject<UAIPerceptionStimuliSourceComponent>(TEXT("StimuliSource"));
StimuliSource->RegisterForSense(UAISense_Sight::StaticClass());
StimuliSource->RegisterForSense(UAISense_Hearing::StaticClass());
StimuliSource->bAutoRegister = true;
Step 2: Configure AI’s perception. On the AIController, add AIPerceptionComponent. Add a SightConfig:
SightConfig:
SightRadius: 2000
LoseSightRadius: 2200
PeripheralVisionAngle: 90
DetectionByAffiliation:
DetectEnemies: true
DetectNeutrals: true
DetectFriendlies: false
Step 3: Set up team affiliation.
// In APlayerController
virtual FGenericTeamId GetGenericTeamId() const override
{
return FGenericTeamId(0); // player team
}
// In AAIController
virtual FGenericTeamId GetGenericTeamId() const override
{
return FGenericTeamId(1); // enemy team
}
Step 4: Subscribe to perception events.
PerceptionComp->OnPerceptionUpdated.AddDynamic(this, &AMyAI::OnPerceptionUpdated);
void AMyAI::OnPerceptionUpdated(const TArray<AActor*>& UpdatedActors)
{
for (AActor* a : UpdatedActors)
{
UE_LOG(LogTemp, Log, TEXT("Detected: %s"), *a->GetName());
}
}
Step 5: Verify with showdebug ai. The on-screen overlay shows perception cones, sight rays, and detection state. Walk the player into view and watch for confirmation.
“Stimulus source on detected. Perception config on AI. Affiliations match. Detection fires.”
Related Issues
For Anim Notify state, see Anim Notify End. For multicast RPC, see Multicast RPC.
Stimulus source. Perception config. Team setup. AI sees the player.