AI Enemy System Guide 中文

Blueprint recipes

Each recipe is drawn as a node chain: execution runs left to right, and each node lists the pins to set. “from” means the pin is wired from that source.

Updated 2026-11-18

Node colorsEventFunctionPure functionFlow controlCastVariableYour own logic

Make guards notice things#

Footsteps#

Where it goesThe player's Animation Blueprint

Event AnimNotify_Footstep
Make Walk Noise
Target is Stealth Noise
Target←Try Get Pawn Owner → Get Component by Class (Stealth Noise)
  • Add an Anim Notify named Footstep to the walk and run animations, and this event appears in the Animation Blueprint.
  • To tell walking, sprinting and crouching apart, use Make Movement Noise and feed State from a Select: Crouching when crouched, Sprinting above 450 horizontal speed, Walking otherwise.
  • The return value is how many guards heard that step, handy for a UI hint.

Make an object noisy (doors, bottles, alarms)#

Where it goesThe Blueprint of the object making the sound

Your event: door opens, bottle lands, alarm goes off
Report Sound At
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Location←Get Actor Location
Radius=800
Instigator←The player (optional)
Tag=Bottle
Wall Attenuation=0.5
  • Radius is how far it can be heard (cm). Wall Attenuation 0.5 halves what's left at each wall; 0 goes through walls completely.
  • Guards walk to where the sound was made, which is exactly what a thrown-object distraction needs.
  • To know who heard it, use Report Sound With Feedback, which returns the guards that heard it.

Report a custom clue#

Where it goesAny Blueprint, for example a cabinet left open

Your event: the cabinet is opened
Report Evidence At
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Type=Custom
Location←Get Actor Location
Lifetime=30
Source←Self
  • Lifetime is how many seconds the clue lasts; 0 means permanent. Keep the returned Id and call Remove Evidence when things are restored.
  • A guard notices it within 1200 cm when it can see the spot. Set Source to the object itself so a trace that hits it still counts.
  • For items that can be taken it's simpler to add an AI Evidence component; see the setup guide.

Restricted area: being seen counts as witnessed#

Where it goesA trigger volume Blueprint

Event ActorBeginOverlap
Other Actor
Cast To BP_ThirdPersonCharacter
Object←Other Actor
Report Witnessable Event At
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Type=Restricted Area Sighting
Location←Other Actor's location
Instigator←Other Actor
  • Only guards that can see the spot right now count as witnesses; if nobody sees it, nothing happens.
  • Witnesses go straight to Alerted, warn allies within 2000 cm, and add 0.1 Belief (more with more witnesses).
  • Staying inside doesn't report again; leaving and coming back does.

React to what guards do#

Player captured#

Where it goesOption A goes in the guard Blueprint; option B in the GameMode or Level Blueprint

Option A: in the guard Blueprint
Event On Player Captured
Player
Do Once
Your fail flow: show the fail screen, restart the level
Option B: bind every guard from the GameMode
Event BeginPlay
Get All Enemies
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Out Enemies
For Each Loop
Array←Out Enemies
Bind Event to On Captured Player
Target←Array Element
Event←HandleCaptured
The event option B binds
Custom Event: HandleCaptured
Enemy
Player
Do Once
Your fail flow
  • The event fires every frame while in range, so the Do Once is required.
  • Option B leaves the shared Guard Blueprint untouched, but only binds guards that exist at BeginPlay; bind spawned guards when you spawn them.
  • Capture needs an Alerted guard, distance within Capture Range (150 cm) and a player who isn't invisible. It doesn't check line of sight.

Act on alert state changes (call allies, change looks)#

Where it goesThe guard Blueprint (Guard or a child of it)

Event On Alert State Changed
Old State
New State
Switch on EEnemyAlertState
Selection←New State
Share Alert
From the Alerted output
Other outputs: play a sound, swap material, change animation
  • A guard that goes Alerted by seeing the player doesn't warn others on its own; Share Alert warns every guard within Alert Share Radius (2000 cm).
  • Every Share Alert also reports an Alarm Raised score event.
  • To switch animations by behavior (patrol, chase, search), use Event On Behavior Changed, which gives the old and new behavior.

Show a guard's emotion color#

Where it goesThe guard Blueprint

Set up the material at start
Event BeginPlay
Create Dynamic Material Instance
Target←Mesh
Element Index=0
Set EmotionMat
EmotionMat←Return Value
Update the color every frame
Event Tick
Set Vector Parameter Value
Target←EmotionMat
Parameter Name=EmotionColor
Value←Emotion → Get Display Color
  • The material needs a Vector parameter named EmotionColor.
  • Get Display Color already includes the flicker during a change. Each emotion's color is set in the emotion component's Emotion Colors.
  • For a quick look while debugging, turn on the emotion component's Draw Debug to draw a ring in that color at the guard's feet.

Player abilities and cards#

Kill or knock out a guard#

Where it goesThe player or ability Blueprint

Kill
Your kill input or ability event
Cast To AIEnemy
Object←Target actor (from a trace or overlap)
Report Killed
Target←As AIEnemy
Killer←Self
Knock out (one punch per call)
Your attack event
Cast To AIEnemy
Object←Target actor
Take Punch
Target←As AIEnemy
Attacker←Self
  • After Report Killed the guard plays its death, leaves a permanent body as evidence, and guards that see it go Alerted.
  • Take Punch needs 10 punches to knock out; use Knock Out for an instant knockout. The guard wakes after 8 seconds.
  • Cast To AIEnemy works for the Guard Blueprint and every child of it.

Steal an emotion#

Where it goesThe steal ability Blueprint

Your steal input or ability event
Cast To AIEnemy
Object←Target actor
Steal Emotion
Target←As AIEnemy
Thief←Self
Out Emotion
Out Card Weight
Branch
Condition←Return Value
True: give a card from Out Emotion and Out Card Weight
  • A false Return Value means nothing was stolen, for example because the guard is dead.
  • Stealing anything other than Calm pacifies the guard for 10 seconds: it returns to patrol and neither sees nor hears.
  • A steal is a witnessable event, so guards watching it go Alerted.

Anger card: make nearby guards fight#

Where it goesThe card or ability Blueprint

Card used
Force State In Radius
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Origin←Get Actor Location
Radius=1500
State=Fight Allies
Duration=10
  • Every living, conscious guard in the radius attacks its nearest fellow guard; the return value is how many were affected.
  • A Duration of 0 or less lasts until Clear Forced State is called.
  • Fighting guards don't capture the player, and their emotions don't change.

Lights out: one lamp or an area#

Where it goesThe snuff ability or blackout card Blueprint

Turn off one lamp
Your snuff event
Turn Off
Target is AI Light
Target←Lamp actor → Get Component by Class (AI Light)
Blackout in an area
Card used
Set Lights In Radius
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Origin←Get Actor Location
Radius=2000
On=false
  • Set Intensity(0) on the light component works too; the AI Light notices it. Dimming without reaching 0 doesn't count.
  • Turn lights back on the same way: Turn On, or Set Lights In Radius with On ticked.
  • Nearby guards come to check when a light goes out; untick Investigate When Turned Off on the AI Light to stop that.

Distraction: lure guards away#

Where it goesThe ability or card Blueprint

Lure several guards: make a noise
Ability event
Report Sound At
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Location←Where to lure them
Radius=1200
Lure one guard
Ability event
Cast To AIEnemyController
Object←Target guard → Get AI Controller
Request Investigate
Target←As AIEnemyController
Location←Where to lure it
  • A noise draws every guard within its radius; Request Investigate moves just one guard.
  • Both make the guard Suspicious for at least 8 seconds. Request Investigate is ignored by a guard that is already Alerted.

Calm nearby guards#

Where it goesThe ability or card Blueprint

Ability event
Get Enemies In Radius
Target is AIEnemySubsystem
Target←Get AIEnemySubsystem
Origin←Get Actor Location
Radius=1000
Out Enemies
For Each Loop
Array←Out Enemies
Pacify
Target←Array Element
Duration=10
  • Pacified guards forget everything and go back to patrol, seeing and hearing nothing meanwhile.
  • A Duration of 0 uses the emotion component's Emotion Suppress Time (10 seconds).

Turn invisible for a while#

Where it goesThe player or ability Blueprint

Invisibility ability event
Add Unique
Target Array←Tags
New Item=InvisibleToAI
Delay
Duration=5
Remove Item
Target Array←Tags
Item=InvisibleToAI
  • Tags is the player actor's own tag array. With InvisibleToAI in it, guards can't see, hear or capture the player, and nothing it does has witnesses.
  • A body left behind is still found: that's evidence, not witnessing.

UI and scoring#

Listen to score events#

Where it goesThe GameMode, HUD or your scoring system

Option A: listen to the subsystem
Event BeginPlay
Bind Event to On Ghost Score Event
Target←Get AIEnemySubsystem
Event←OnScoreEvent
The event option A binds
Custom Event: OnScoreEvent
Event
Switch on EGhostScoreEvent
Selection←Break Ghost Score Event Data → Type
Each output: change your score
Option B: use the bundled Ghost Score component
Event BeginPlay
Bind Event to On Score Changed
Target←Ghost Score
Event←An event that updates the score UI
  • Five events: Spotted Player, Detected Player, Noise Heard, Alarm Raised, Guard Dead. A guard reports Spotted Player and Noise Heard once per alert cycle.
  • Put the Ghost Score component on the player and it scores automatically (starting at 1000); On Score Changed gives the new total, the change and the reason.

Tell the player they're in the dark#

Where it goesThe player Blueprint or HUD

Event Tick
Branch
Condition←Get AIEnemySubsystem → Is Location Dark (Get Actor Location)
Set Visibility
Target←The “in the dark” icon widget
In Visibility=Visible on True, Hidden on False
  • Is Location Dark uses the same rule as guards: dark only where an AI Light covers the spot and every light covering it is off.
  • It doesn't need to run every frame; a Set Timer by Event every 0.2 seconds is plenty.