Skip to content

Seeing the player: Pawn Sensing & AI Perception

At a glance

Lives in: Blueprint API / AI / Components for Pawn Sensing, and AI Perception for the newer perception system - Returns: events such as On See Pawn, On Hear Noise, On Perception Updated, and On Target Perception Updated - Changes: nothing by itself except perception state; your graph decides whether to chase, attack, remember, or forget - Can fail by: missing component, disabled sense, bad sight radius/cone, blocked line of sight, target not registered as a stimulus, affiliation filters, sensing interval timing, or setting a "player seen" variable and never clearing it - Official docs: AI Perception, UPawnSensingComponent, and Get Peripheral Vision Angle

The one-minute version

  • Pawn Sensing is the simple beginner path. Add a Pawn Sensing component to an enemy pawn, bind On See Pawn, filter the seen pawn, then start chase logic such as AI Move To.
  • On See Pawn fires when the component sees a pawn. It does not automatically chase, attack, store a target, or forget a target.
  • The main sight settings are sight radius and peripheral vision angle. The target also needs to be in line of sight and checked during the component's sensing updates.
  • If your AI "never forgets," you probably set a TargetPawn or bCanSeePlayer variable on On See Pawn and never cleared it.
  • AI Perception is the larger system. Use it when you need sight plus hearing/damage, stronger memory behavior, stimuli sources, debugger support, or a path toward Behavior Trees.
  • In AI Perception, On Target Perception Updated gives you the actor plus an AI Stimulus. Break the stimulus and check Successfully Sensed.
  • Behavior Trees, EQS, team attitude systems, and custom senses sit past the beginner core. This page gets the first enemy seeing and chasing.

Beginner path: Pawn Sensing

Pawn Sensing is the shortest first-enemy setup:

BP_EnemyCharacter
-> Add Component: Pawn Sensing
-> set Sight Radius, Peripheral Vision Angle, and sensing options
-> Events:
   On See Pawn
       Seen Pawn -> Cast/Interface/filter for player
       Set TargetPawn
       AI Move To Target Actor = TargetPawn

That is enough to prove the loop:

enemy sees player
-> event fires
-> target variable is assigned
-> enemy starts a move request

Do not put all enemy behavior inside the sensing event forever. The event is the notification that something was sensed. Chasing, attacking, giving up, and returning to patrol are separate behavior decisions.

Pawn Sensing settings that matter

Setting Beginner meaning
Sight Radius How far this component can see pawns.
Peripheral Vision Angle Half-angle of the sight cone from the component owner's forward direction. Wider means more side vision.
See Pawns Whether pawn sight checks are enabled.
Hear Noises Whether noise/hearing checks are enabled.
Sensing Interval How often the component checks. Lower reacts faster but costs more.
Only Sense Players Whether it should ignore non-player pawns.

Peripheral vision is measured from the forward direction, so a value of 45 means roughly 45 degrees to either side of forward, not a 45-degree total cone. Use Set Peripheral Vision Angle if the cone needs to change at runtime.

If the enemy sees behind itself, check which component/actor direction is being used as forward and whether the mesh is visually rotated relative to the root. The sensor sees according to the owning pawn/component setup, not according to where the imported mesh art appears to face.

On See Pawn does not mean "player is still visible"

On See Pawn is an event. It tells you the component saw a pawn during a sensing update. A beginner graph often does this:

On See Pawn
-> Set bCanSeePlayer = true
-> AI Move To player

Then the AI never forgets because nothing ever sets bCanSeePlayer back to false.

For Pawn Sensing, add your own memory rule:

Variables:
    TargetPawn
    LastSeenTime
    LoseSightAfter = 2.0

On See Pawn
-> if pawn is player:
       TargetPawn = SeenPawn
       LastSeenTime = Get Game Time in Seconds
       AI Move To TargetPawn

Timer every 0.25 seconds
-> if TargetPawn is valid
-> if GameTime - LastSeenTime > LoseSightAfter:
       TargetPawn = None
       stop chase / return to patrol

That is not the only design. You might keep chasing to the last known location, search for a few seconds, or attack if already in range. The point is that forgetting is behavior you define.

Sight is not a magic wallhack

If On See Pawn never fires, check the physical situation:

  • Is the player pawn inside Sight Radius?
  • Is the player inside the peripheral vision cone?
  • Is line of sight blocked by walls, doors, or collision?
  • Is the enemy facing the way you think it is?
  • Is the Pawn Sensing component enabled and allowed to see pawns?
  • Is Only Sense Players filtering out the pawn you are testing?
  • Is the sensing interval slow enough that you are missing a brief pass through the cone?

For debugging, print the seen pawn's name in On See Pawn, then draw or reason about the cone/radius. If you need exact "can I see this target right now?" checks, pair sensing with a line trace or use AI Perception's current/known perceived actor queries.

AI Perception: when to graduate

AI Perception is the broader Unreal AI sensing system. It uses an AIPerceptionComponent as the listener and configured senses such as Sight, Hearing, Damage, Team, Touch, and Prediction.

Use AI Perception when:

  • you need sight plus hearing, damage, or other stimulus types;
  • you need better "currently perceived" vs "known but stale" queries;
  • you want debugger support through the AI Debugger;
  • non-pawn actors such as pickups, noises, or interactables should be perception stimuli;
  • you are moving toward Behavior Trees or a larger AIController setup.

The usual first setup puts the AI Perception component on the AIController:

BP_EnemyAIController
-> Add Component: AI Perception
-> Senses Config: AI Sight
   Sight Radius
   Lose Sight Radius
   Peripheral Vision Half Angle Degrees
   Detection by Affiliation
   Max Age
-> Event: On Target Perception Updated

On the event:

On Target Perception Updated(Actor, Stimulus)
-> Break AI Stimulus
-> Branch Successfully Sensed
   true:
       set TargetActor = Actor
       AI Move To Actor
   false:
       set LastKnownLocation = Stimulus Location
       start search / forget timer / clear target depending on design

The event gives you perception information. It does not choose your enemy's behavior for you.

Stimuli sources

AI Perception senses receive stimuli from actors/systems. The AIPerceptionStimuliSourceComponent lets an actor register itself as a source for one or more senses.

Use a Stimuli Source when:

  • a non-pawn actor should be detected by sight or another sense;
  • you want the target actor's perception setup to be explicit;
  • project settings or custom perception code changed default source behavior;
  • a noise/item/object should register or unregister as part of gameplay.

Important settings:

Setting Beginner meaning
Auto Register as Source Register this actor automatically when active.
Register as Source for Senses Which senses this actor can stimulate.
Register / Unregister functions Turn source participation on or off deliberately.

If AI Perception never detects the player, check both sides: the listener component/sight config on the AI side, and whether the thing you expect to detect is actually a valid stimulus source for that sense.

Why AI Perception "never forgets"

There are two different problems beginners call "never forgets."

Your Blueprint variable never clears

This is the same trap as Pawn Sensing:

Successfully Sensed true
-> TargetActor = Player

// no false/stale/timeout path

Fix it by handling Successfully Sensed = false, using timers, storing last known location, or clearing the target when the stimulus expires.

Perception memory is configured to remember

AI Perception sense configs have Max Age. Epic's docs describe 0 as "never forgotten." The docs also call out that forgetting stale actors requires Project Settings -> Engine -> AI System -> Forget Stale Actors to be true, then Max Age controls timeout.

So the debug checklist is:

  1. Is Max Age set to a real duration rather than 0?
  2. Is Forget Stale Actors enabled if you expect stale actors to be forgotten?
  3. Are you responding to Successfully Sensed = false?
  4. Are you clearing your own TargetActor variable?
  5. Are you confusing "known perceived actor" with "currently perceived actor"?

Get Currently Perceived Actors and Get Known Perceived Actors answer different questions. Current means perceived now by the requested sense. Known means remembered/not forgotten.

From seeing to chasing

Sensing does not move the enemy. AI movement still needs the setup from AI Move To & the NavMesh:

On See Pawn or Successfully Sensed true
-> filter target
-> Set TargetActor
-> AI Move To Target Actor

On lost sight / timeout / Successfully Sensed false
-> Stop Movement or move to LastKnownLocation
-> clear TargetActor when search gives up

Do not fire a brand-new move request every sensing tick unless that is deliberate. A clean first design starts chase on acquisition, updates or reissues move requests at a controlled interval, and has a clear lost-target branch.

Debugging

For Pawn Sensing:

  • print from On See Pawn;
  • print the seen pawn class/name;
  • temporarily widen radius and peripheral angle;
  • check enemy forward direction;
  • check walls/collision between enemy and player;
  • lower sensing interval temporarily while testing.

For AI Perception:

  • use the AI Debugger while playing: apostrophe (') opens it, Numpad 4 shows Perception information;
  • print Successfully Sensed, Stimulus Location, and Actor name;
  • check Sight Radius, Lose Sight Radius, Max Age, Starts Enabled, and Detection by Affiliation;
  • add or inspect an AIPerception Stimuli Source on actors that should be detected;
  • compare Get Currently Perceived Actors with Get Known Perceived Actors.

For both systems, use breakpoints on the event that should fire. If the event never fires, the problem is sensing setup. If it fires but the enemy does not move, the problem is behavior, target filtering, or AI movement setup.

Lookalikes - which one do I want?

Tool Use when Watch out
Pawn Sensing A first enemy needs simple pawn sight/hearing events. No full memory/forget behavior unless you add it.
AI Perception You need configurable senses, stimuli, memory, debugger, and AIController-friendly setup. More setup and more concepts.
Line Trace By Channel You need one immediate line-of-sight/raycast question. It is not a persistent sensing system.
On Component Begin Overlap A trigger volume should detect entering/leaving. Not vision; ignores facing and line of sight unless you add checks.
AI Move To An AI should move after it has a target. It does not sense anything.
Behavior Tree AI decision logic is becoming a state machine of patrol/chase/search/attack. Past the beginner-core boundary for this page.
EQS AI needs to choose good tactical positions from environmental queries. Also past this first-enemy boundary.

The C++ twin

For the curious, Pawn Sensing in C++ usually binds the component event to your own handler (our own example code):

void ATrainingEnemy::BeginPlay()
{
    Super::BeginPlay();

    if (IsValid(PawnSensing))
    {
        PawnSensing->OnSeePawn.AddDynamic(
            this,
            &ATrainingEnemy::HandleSeePawn);
    }
}

void ATrainingEnemy::HandleSeePawn(APawn* SeenPawn)
{
    if (!IsValid(SeenPawn) || !SeenPawn->IsPlayerControlled())
    {
        return;
    }

    TargetPawn = SeenPawn;
    LastSeenTime = GetWorld()->GetTimeSeconds();
    StartChasingTarget();
}

AI Perception C++ usually binds perception-component update delegates on the AIController or controller-owned component, then reads the stimulus data before updating blackboard or controller variables.

Going deeper