[UE5] Getting Enemies to Notice You with AI Perception: Sight, Hearing, and What Happens After Losing You

Created: 2026-07-20

Your enemy never notices the player, or spots them through walls. This article diagrams how to configure sight and hearing with UE5's AI Perception and receive detection and loss through On Target Perception Updated, with a hands-on build of a guard that searches the last known spot for 5 seconds before returning to patrol.

You got your enemy patrolling. But when the player walks right past it, nothing happens. You tweak the settings and now the opposite happens: the enemy makes a beeline for a player who's supposedly behind a wall.

UE5 has an AI Perception Component dedicated to this "noticing" part. You don't need to compute distances and angles yourself, and you don't need to write traces for walls blocking line of sight. This article covers sight and hearing settings, how to receive detection and loss, and the setting that most often causes detection to silently fail.

Illustration of an enemy noticing the player the instant they step into its cone of vision

What You'll Learn

  • Perception is a pairing of the sensing side (AI Perception) and the sensed side (Stimuli Source)
  • Sight's three radii and angle (Sight Radius / Lose Sight Radius / Peripheral Vision Half Angle)
  • The usual cause of nothing being detected is Detection by Affiliation
  • Hearing means building the side that makes the noise with Report Noise Event
  • Hands-on: a guard that searches the last known spot for 5 seconds and returns to patrol

Sponsored

How This Splits with Behavior Trees

Building enemy AI brings in two systems, which is easy to muddle. Their responsibilities are cleanly separated.

SystemResponsibilityIn a word
AI PerceptionSenses the surroundingsDo I notice?
Behavior TreeChooses actions based on what was sensedWhat do I do?
BlackboardThe memory connecting the twoWhat to remember

AI Perception decides no behavior at all. It only reports "this Actor came into view" and "it left view." You take that, write it to the Blackboard, and the Behavior Tree reads the value to pick a branch.

This article focuses on the perception side. Reading the Behavior Tree article first makes the hands-on section here a direct continuation of it.

The Sensing Side and the Sensed Side

Perception only works when both pieces are in place. One alone does nothing.

Diagram showing an AI Controller with a field of view on the left and a perceivable target on the right, with detection happening only when both are present
PieceAttach toRole
AI Perception ComponentThe AI ControllerThe sensing side. Holds sight and hearing settings
AI Perception Stimuli Source ComponentThe Actor being perceivedRegisters "there's something perceivable here"

You can attach an AI Perception Component to a Pawn, but attaching it to the AI Controller is standard, because the AI's decision-making stays on the Controller even when the Pawn is swapped.

For the sensed side, there's one behavior worth knowing. Pawns (including Characters) are registered as sources automatically. So if all you want is to detect the Third Person player character, you don't need a Stimuli Source component.

You need it when you want to perceive a regular Actor that isn't a Pawn: a breakable barrel, a dropped piece of gear, a glowing marker. In that case, add the component and configure it in the details panel.

SettingValue
Auto Register as SourceCheck it
Register as Source for SensesAdd AISense_Sight to the array (or AISense_Hearing for hearing)

Register as Source for Senses is empty by default. Leave it empty and the component registers with no sense at all, so it's never detected. When something other than a Pawn refuses to be perceived, look here first.

Sponsored

Sight Settings: How Far and at What Angle

Select AIPerception on the AI Controller and add AI Sight config to Senses Config in the details panel. That's the actual field of view.

Top-down diagram with concentric Sight Radius and Lose Sight Radius circles overlaid with the Peripheral Vision Half Angle cone
SettingMeaning
Sight RadiusThe distance at which it can spot you. Nothing is found beyond it
Lose Sight RadiusThe distance at which it loses you. Make it larger than Sight Radius
Peripheral Vision Half AngleThe angle to one side of forward (degrees). Default is 90, giving a 180-degree field of view
Auto Success Range from Last Seen LocationOnce seen, a target stays visible within this distance regardless of cover or angle. Default -1.0, disabled
Max AgeHow many seconds perceived information is retained. 0 means no expiry

There are two radii to prevent flickering at the boundary. With only one, a player pacing back and forth across that distance triggers "found" and "lost" alternating at high speed. Making the losing side wider, like Sight Radius 1200 / Lose Sight Radius 1600, gives you an AI that clings persistently once it spots someone.

Note that Peripheral Vision Half Angle is half the angle. Enter 60 and the field of view is 120 degrees total. Enter 90 and it's 180 degrees, meaning it can see straight out to the sides.

Line-of-sight blocking is handled automatically. A line is drawn between the AI and the target, and if it's blocked, the target counts as unseen. The channel used for that check is Default Sight Collision Channel under Project Settings > Engine > AI System (default Visibility). When enemies spot you through walls, check whether that wall's collision blocks this channel (see the collision profile article).

The Biggest Reason Nothing Gets Detected

You entered all the settings correctly and nothing happens. Almost always the cause is Detection by Affiliation.

Diagram showing that in the default state with only Detect Enemies enabled, Blueprints treated as neutral are never detected

Three checkboxes inside AI Sight config decide which factions get perceived.

SettingDefaultMeaning
Detect EnemiesOnPerceive hostiles
Detect NeutralsOffPerceive neutrals
Detect FriendliesOffPerceive allies

And the important part is how teams are determined. UE treats Actors implementing IGenericTeamAgentInterface as having a team, and that isn't configurable from Blueprint by default.

The upshot is that every Actor built purely in Blueprint is treated as neutral. Since Detect Neutrals is off by default, nothing happens even when they walk into view.

While you're testing in Blueprint, check Detect Neutrals. That alone gets things moving.

But left like that, enemies detect each other too. If you want them to target only the player, you need to filter by Tag or class after you receive the perceived Actor. That's covered in the next section.

Sponsored

Receiving Detection and Loss

Add the On Target Perception Updated event from the bottom of the AI Perception Component's details panel. It fires only the moment perception state changes.

It has two pins.

PinTypeContents
ActorActorThe one whose state changed
StimulusAIStimulus (struct)Details of what happened

Stimulus is a struct, so pull its contents out with Break AIStimulus. Three members see the most use.

MemberContents
Successfully Sensedtrue means perceived, false means lost
Stimulus LocationWhere the perceived target was. On loss, this holds the last confirmed position
TagThe name attached to the stimulus. Set it via Report Noise Event

In other words, this single event delivers both detection and loss.

Diagram showing the single On Target Perception Updated event branching on Successfully Sensed: true leads to chasing, false leads to heading for the last known spot
Event On Target Perception Updated (Actor, Stimulus)
  → Break AIStimulus (Stimulus)
  → Branch (Condition: Successfully Sensed)
      True  → (found them)
      False → (lost them. Stimulus Location is the last seen position)

The handy part is that Stimulus Location works as "the last seen position." You don't need to fire a separate trace the moment you lose them.

Hearing Means Building the Noise Maker

Unlike sight, hearing doesn't work just because a sound plays. Sound coming out of your speakers and sound the AI hears are entirely separate systems (see the 3D sound article).

Diagram of noise spreading in concentric circles from a footstep's origin, with only AI inside the range reacting

On the listening side, add AI Hearing config to Senses Config.

SettingMeaning
Hearing RangeHow far it can hear
Detection by AffiliationSame as Sight. Detect Neutrals is needed here too

On the emitting side, call the Report Noise Event node. Run it whenever you want the AI to notice: footsteps, gunshots, something breaking.

ArgumentMeaning
Noise LocationWhere the sound occurred
LoudnessA multiplier on volume. Scales the distance it carries
InstigatorThe Actor that made the noise. The AI receives this Actor as the perception target (don't omit it)
Max RangeMaximum distance it carries. 0 leaves it to the listener's Hearing Range
TagThe name to attach to this sound
(while running, on every footfall)
  → Report Noise Event (Noise Location: own location, Loudness: 1.0,
                        Instigator: self, Max Range: 0.0, Tag: "Noise")

Always fill in Instigator. Leave it empty and the hearing event may not be processed correctly. Don't think of it as "arrives without knowing whose sound it was." Assume it doesn't arrive at all, and always pass the Actor that made the noise.

Attaching a Tag lets the receiving side tell sight and hearing apart. Stimuli perceived by sight have an empty Tag, so branching on Tag == "Noise" separates "saw it" from "heard it." The hands-on section uses this.

Note: Actors also have a Make Noise node, which likewise takes Loudness and Tag. But it's a system that includes compatibility with the older Pawn Noise Emitter / Pawn Sensing path, which makes the route harder to follow. For delivering straight to AI Perception, Report Noise Event is the more direct choice.

Sponsored

Hands-On: A Guard That Searches the Last Known Spot for 5 Seconds

A guard in a stealth game, a wanderer in a horror game, a field monster in an action RPG. "Chase when you spot them, investigate where they were last seen, give up and return to patrol" is standard enemy AI behavior across genres.

An AI that only chases the moment it spots you goes right back to patrolling as if nothing happened the instant you step behind cover. Whether that "investigation time" exists changes how the AI feels enormously.

The Finished Result

Diagram of the flow where a patrolling enemy chases a player who enters its view, loses them behind a pillar, walks to the last known spot, mills around for 5 seconds, and returns to patrol

The enemy patrols within an area, and chases when the player enters its forward 120 degrees within 12m. Hide behind a pillar and it walks over to near the spot where the player was last seen, stays for 5 seconds, then returns to patrol.

The 5 seconds is a wait after arriving. It isn't 5 seconds including travel time. And since Acceptable Radius: 100 is specified, it stops within 1m rather than exactly on the point.

Setup to Follow Along

Create a new project from the Third Person template.

Prerequisite: this hands-on builds on the setup from the Behavior Tree article. Start from a working patrol-only enemy (including BTT_FindPatrolLocation). Here we only cover adding the "noticing" branch.

You can create the Blackboard and Behavior Tree from right-click in the Content Browser → Artificial Intelligence.

TypeNameSettings
CharacterBP_EnemyAI Controller Class set to BP_EnemyAIController, Auto Possess AI set to Placed in World (use Placed in World or Spawned if you also spawn at runtime)
AIControllerBP_EnemyAIControllerAdd an AIPerception Component
BlackboardBB_EnemyThree keys (table below)
Behavior TreeBT_EnemyBlackboard Asset set to BB_Enemy
BTTaskBTT_ClearLastKnownCreate via Blueprint ClassAll ClassesBTTask_BlueprintBase (you can't make it from the Artificial Intelligence menu)
LevelNav Mesh Bounds VolumeSized to cover the floor. Press P and confirm it turns green
LevelPillar or wall Static MeshesSomething to block sight. Their collision must block Visibility
PlayerBP_ThirdPersonCharacterAdd Player to Actor Tags

To also test hearing, you need something on the player side that makes noise. For testing, adding this to BP_ThirdPersonCharacter's event graph is the easy route.

N (Keyboard Event)
  → Report Noise Event (Noise Location: Get Actor Location, Loudness: 1.0,
                        Instigator: self, Max Range: 0.0, Tag: "Noise")

Now pressing N generates a noise at your position. To tie it to footsteps, call the same node from an Animation Notify.

There are three Blackboard keys.

Key nameTypeDefaultPurpose
TargetActorObject (Base Class: Actor)EmptyWho to chase
LastKnownLocationVectorEmptyWhere they were last seen
PatrolLocationVectorEmptyThe next patrol point

Step 1: Configure Sight and Hearing

Select AIPerception on BP_EnemyAIController and add two entries to Senses Config.

AI Sight config

SettingValue
Sight Radius1200.0 (12m)
Lose Sight Radius1600.0
Peripheral Vision Half Angle60.0 = a 120-degree field of view
Auto Success Range from Last Seen Location-1.0 (leave disabled)
Detect NeutralsChecked

AI Hearing config

SettingValue
Hearing Range2000.0 (20m)
Detect NeutralsChecked

Detect Neutrals is needed on both. Checking only one and then puzzling over "it reacts to sound but can't see me" is a common pattern.

Step 2: Receive Perception and Write to the Blackboard

Add On Target Perception Updated to BP_EnemyAIController's event graph and build the following. This is the heart of the article.

Node graph running from On Target Perception Updated through a Tag check and a sound-versus-sight branch, writing TargetActor and LastKnownLocation separately
Event On Target Perception Updated (Actor, Stimulus)
  → Break AIStimulus (Stimulus) → Successfully Sensed / Stimulus Location / Tag
  → Actor Has Tag (Target: Actor, Tag: "Player")
  → Branch
      False → (do nothing)                          ← ignore anything but the player
      True  → Branch (Condition: Tag == "Noise")
          True  → Branch (Condition: Successfully Sensed)
              True → Set Value as Vector (Key Name: LastKnownLocation)  ← [heard it]
                       (Key: LastKnownLocation, Value: Stimulus Location)
          False → Branch (Condition: Successfully Sensed)
              True  → Set Value as Object (Key Name: TargetActor)    ← [spotted them]
                        (Key: TargetActor, Object: Actor)
              False → Branch (Condition: Actor == Get Blackboard Value as Actor (TargetActor))
                  True → Set Value as Vector (Key Name: LastKnownLocation) ← [lost them]
                           (Key: LastKnownLocation, Value: Stimulus Location)
                       → Clear Value (Key Name: TargetActor)

The crux is that there are three distinct writes.

  • Spotted them: put the target in TargetActor. Chasing begins
  • Lost them: save the last coordinates to LastKnownLocation first, then clear TargetActor. Reverse the order and the chase stops with nowhere to search
  • Heard it: write only LastKnownLocation and don't touch TargetActor. A sound doesn't mean you can see them, so not chasing directly is the natural behavior

Successfully Sensed is checked on the hearing path too because a notification also arrives when a stimulus expires. Skip it and the AI keeps heading back to the position of an old sound.

The Actor == TargetActor check on the loss path is there to prevent losing sight of some unrelated Actor from wiping your target.

Watch out: the nodes involved here come in two families.

Where you use itNodeHow the key is specified
Operating from the AI ControllerSet Value as Object / Set Value as Vector / Clear ValueKey Name (a string)
Operating inside a BTTask BlueprintSet Blackboard Value as ... / Clear Blackboard ValueA Blackboard Key Selector variable

We're writing in the AI Controller here, so use the former. Wire the return value of Get Blackboard into the Target pin. Leave it empty and nothing gets written, with no error.

Typing "Set Blackboard Value" in the search box surfaces the latter family first, so always confirm that the Target pin is a Blackboard Component.

Don't forget to start the tree.

Event On Possess (BP_EnemyAIController)
  → Run Behavior Tree (BTAsset: BT_Enemy)

Step 3: Add the Search Branch to the Behavior Tree

Give BT_Enemy three branches. Left means higher priority.

Behavior Tree diagram with three Sequences under the root Selector: chase, investigate, and patrol
Root
└─ Selector
   ├─ Sequence "Chase"
   │   ⚑ Decorator: Blackboard (TargetActor is Set / Observer aborts: Both)
   │   └─ Task: Move To (Blackboard Key: TargetActor, Acceptable Radius: 200)
   │
   ├─ Sequence "Investigate the last spot"
   │   ⚑ Decorator: Blackboard (LastKnownLocation is Set / Observer aborts: Both)
   │   ├─ Task: Move To (Blackboard Key: LastKnownLocation, Acceptable Radius: 100)  ← stops within 1m, not exactly on the point
   │   ├─ Task: Wait (Wait Time: 5.0)          ← this is the "search for 5 seconds"
   │   └─ Task: BTT_ClearLastKnown              ← done investigating, so forget it
   │
   └─ Sequence "Patrol"
       ├─ Task: BTT_FindPatrolLocation
       ├─ Task: Move To (Blackboard Key: PatrolLocation)
       └─ Task: Wait (Wait Time: 2.0)

The middle branch is what we're adding. Putting BTT_ClearLastKnown at the end matters. Without it, LastKnownLocation sticks around and the enemy paces back to the same spot forever.

BTT_ClearLastKnown is three nodes.

Variable: TargetKey (Blackboard Key Selector type, Instance Editable)

Event Receive Execute AI
  → Clear Blackboard Value (Key: TargetKey)
  → Finish Execute (Success: true)

Select this Task in the Behavior Tree and assign LastKnownLocation to Target Key in the details panel.

BTT_FindPatrolLocation is the same one from the Behavior Tree article: a Task that finds a point with Get Random Reachable Point in Radius and writes it to PatrolLocation.

Don't forget to set the Decorators' Observer aborts to Both. Leave it at None and spotting the player does nothing until the patrol's Wait finishes.

Verify It

Place BP_Enemy in the level, hit Play, and try these in order.

  1. Approach from behind the enemy. Even within 12m, nothing happens. The field of view is 120 degrees forward, so directly behind is blind
  2. Circle around to the front. The moment you're within 12m, the enemy stops patrolling and comes at you
  3. Step behind a pillar. The enemy walks to the spot where the player was last visible, stays there for 5 seconds, then goes back to random patrolling
  4. Peek out from the other side of the pillar during those 5 seconds. It spots you again and the chase resumes

Play with the Behavior Tree open and the executing node lights up, while the Blackboard panel lets you follow the contents of TargetActor and LastKnownLocation. Watching the moment values are written and cleared tells you immediately where things are stalling.

Here's how to narrow things down when it doesn't work.

  • Nothing happens when you walk into viewDetect Neutrals isn't checked. This is the first thing to suspect
  • TargetActor in the Blackboard stays empty → the player's Actor Tag isn't Player, or it's misspelled
  • Spots you through walls → that wall's collision doesn't block the Visibility channel
  • Spots you from directly behindPeripheral Vision Half Angle is still the default 90 (a 180-degree view)
  • Keeps chasing after losing youLose Sight Radius is too large, or you entered a value in Auto Success Range from Last Seen Location
  • Paces back to the same spot foreverBTT_ClearLastKnown is missing, or Target Key is unassigned
  • Enemies chase each other → you aren't running the Tag check
  • Doesn't move at all → Nav Mesh Bounds Volume (check with P) and Auto Possess AI

Once you have it moving, try entering 400 in Auto Success Range from Last Seen Location. Once spotted, you stay visible within 4m even behind a pillar. That closing tension of "once they've noticed you, you can't fully hide up close" comes from this one setting.

There are two key points.

  • Always translate perception results into Blackboard values: driving the character directly from AI Perception means managing state in two places alongside the Behavior Tree's decisions. Splitting it so Perception only writes and the tree alone decides behavior keeps things intact when you add branches later
  • Don't treat "saw" and "heard" the same: sound doesn't put eyes on the target, so it lands in LastKnownLocation instead of TargetActor. That distinction alone gives you the natural behavior of "go look toward the noise"

When you're ready to tune chase speed and attack spacing, see NavMesh settings. If you want to compare against building sight yourself, see the Line Trace article.

Sponsored

Bonus: Good to Know for Later

Change the music on detection. On Target Perception Updated doesn't only drive enemy behavior — it's also a natural hook for the soundtrack. Stack a combat layer on detection and pull it back on loss, all from one float (→ Interactive Music).

See the field of view you configured. How far Sight Radius and Peripheral Vision Half Angle actually reach isn't knowable until you draw them. Adding a Draw Debug Sphere and Draw Debug Cone, or rewinding in Visual Logger, answers it instantly (→ Draw Debug and Visual Logger).

  • See the field of view with the Gameplay Debugger: press ' (apostrophe) during Play to open the Gameplay Debugger, and switch categories with the number keys. Displaying the Perception category draws the sight range and currently perceived targets in the viewport. Look at it before you start guessing at numbers (see the debug display article)
  • Dominant Sense is "the preferred sense when queried": set it to AISense_Sight and sight information is prioritized when you ask the Perception Component for a target's location. However, it has no effect in a setup like ours, where you write Stimulus Location to the Blackboard yourself per event. You have to decide the priority on the writing side
  • Tune Max Age to your use case: how many seconds perceived information is retained. 0 means no expiry. Short if you want it forgotten in a few seconds, long if you want it remembered once noticed
  • There's a damage sense too: add AI Damage sense config and the AI can react to being shot from behind. The damaging side needs to call Report Damage Event (see the damage handling article)
  • The sensing and sensed sides use different reference points: the sensing side (the AI) uses the position and direction based on Get Actor Eyes View Point. The sensed side, by default, uses the Actor's location. To handle crouching and cover precisely, implement IAISightTargetInterface on the sensed side to specify the test points
  • Proper team assignment requires C++: implementing IGenericTeamAgentInterface can't be done in Blueprint alone. When you want to seriously separate enemies, allies, and neutrals, implementing it on the AI Controller in C++ is the standard route (see First Steps into C++)

Summary

AI Perception has plenty of settings, but the skeleton you need to grasp is small.

ElementRole
AI Perception ComponentAttached to the AI Controller. The sensing side
Stimuli Source ComponentAttached to the sensed side. Not needed for Pawns, which register automatically
AI Sight configTwo distances (Sight / Lose Sight) plus the half-angle
AI Hearing configA distance. The emitting side uses Report Noise Event
Detection by AffiliationDefaults to Detect Enemies only. Use Detect Neutrals while testing in BP
On Target Perception UpdatedDelivers both detection and loss. Split them with Successfully Sensed

And one design guideline: Perception only writes, and the Behavior Tree decides behavior. Hold that boundary and adding behaviors like "search for the hiding player" or "alert nearby allies" only means touching the tree.

How long do you want your enemies to keep looking after they lose the player?