Level setup
Follow the steps; each one is a single action in the editor. Then use “How to check it works” to confirm.
Place a patrolling guard#
Drag it in, add a navmesh and patrol points; it runs in a few minutes.
- Drag /Game/Benjamin-AI/Enemy/Guard into the level. The controller possesses it automatically, so there's no need to set AI Controller Class.
- Add a NavMeshBoundsVolume over the area the guard walks. Press P in the viewport; green navmesh means it's built.
- Place a few Target Points as patrol points.
- Select the guard → Details → AI → Behavior → Patrol Points, press + a few times, and pick each point with the eyedropper.
- Set Loop Patrol (back to the first point, or the same path back), Patrol Wait Time (seconds at each point) and Patrol Speed as needed.
- With no patrol points the guard stands guard where you placed it, facing the way you placed it. Random Patrol Radius above 0 makes it wander nearby instead.
How to check it worksTurn on the guard's Draw Debug and play: the cone moves with the guard, the text over it says Unaware, and the magenta line above says Patrol.
Make the player's footsteps heard#
Give the player Stealth Noise and call a noise node on every step.
- Player Blueprint → Add Component → Stealth Noise. The formal project's BP_ThirdPersonCharacter already has it.
- Add an Anim Notify to the walk and run animations, for example named Footstep.
- In the Animation Blueprint, wire Event AnimNotify_Footstep → Make Walk Noise, targeting the player's Stealth Noise. The Footsteps recipe shows the full wiring.
- To skip the notifies, the editor function Wire Stealth Noise Footsteps wires it into the character Blueprint's Tick in one go.
- Tune the radii on Stealth Noise: walk 500 cm, sprint 1400 cm, crouch 0 (silent); wall attenuation 0.5.
How to check it worksTurn on Stealth Noise's Draw Debug: rings spread from your feet as you move, and guards that hear you get a line to the player.
Place a light that affects AI sight#
Place a lamp from scratch: while it's lit guards see normally; once it's off, the area is dark to them.
- Drag a Point Light from the Place Actors panel to where it should shine (a Spot Light or Rect Light works too). If the team's BP_LightParent already has AI Light, drag that in instead and skip step 3.
- Select the light → Details → set Mobility to Movable. Every light that switches at runtime needs this, or it still looks lit after it goes off.
- Details → + Add → search AI Light → add it. Guards need no setup.
- Set the AI Light's Radius; 0 uses the light's Attenuation Radius. The dark area is a sphere around the light, checked at a character's waist (about 90 cm up), so the higher the lamp, the larger Radius must be.
- Turn on the AI Light's Draw Debug. In PIE a yellow circle shows on the floor: that's the area this lamp controls, so make it cover the floor you want to go dark.
- To make the spot dark from the start, untick the light's Visible.
How to check it worksIn PIE, press F8 to leave the character, select the light and untick Visible: the circle turns dark blue and nearby guards come to check. With the player inside the circle, the guard's text shows Player Dark and its cone toward the player shrinks to 225 cm / 18°.
Make existing lights affect guard sight#
Add AI Light to the lamps you already have; where they're off, guards only see a short way.
- If the lamp is BP_LightParent: open it → Add Component → AI Light → compile and save. It's a shared asset, so check it out first and tell its author.
- For a light placed directly in the level: select it → Details → + Add → AI Light.
- Lights that switch at runtime should be Movable or Stationary.
- For lamps hung high, raise the AI Light's Radius so the lamp's height minus 90 cm stays below Radius; otherwise no floor is covered.
- Turn lights off with Set Intensity(0), Set Visibility(false) or the AI Light's Turn Off, and back on the same way.
- For an area that starts dark, place a light with Visible unchecked and add an AI Light to it.
How to check it worksTurn on the AI Light's Draw Debug: a yellow circle appears on the floor in PIE, it turns dark blue when the light goes out, and nearby guards come to check.
Make a taken item get noticed#
Give the item AI Evidence; destroying it reports “item missing” automatically.
- Item actor → Add Component → AI Evidence.
- Set Evidence Type to Item Missing and keep Report When Owner Destroyed on.
- When the player takes the item, destroy the actor; an Item Missing is reported where it was.
- If the item is hidden rather than destroyed, call the AI Evidence's Report Change, and Retract Last Change when it's put back.
- Notice Radius (default 1200 cm) sets how far away it can be noticed; Require Line Of Sight sets whether the guard must see the spot.
How to check it worksWith the guard's Draw Debug on: when it notices the evidence, the text over it turns Suspicious and a purple ball marks the spot.
Handle the player getting caught#
C++ only fires an event; wire your own fail flow and make sure it runs once.
- Guards only capture while Alerted and within Capture Range (150 cm) of the player. C++ never ends the game.
- Wire Event On Player Captured in the guard Blueprint, or bind On Captured Player on every guard from the GameMode. See the Player captured recipe.
- The event fires every frame while in range, so always follow it with a Do Once or your own flag.
- Capture doesn't check line of sight, so a thin wall doesn't stop it. Lower Capture Range if that matters.
How to check it worksGet caught on purpose once and confirm the fail flow ran only once.
Try everything in the test level#
LV_AITest has zones set up for sight, hearing, lights and witnesses.
- Open /Game/Benjamin-AI/LV/LV_AITest.
- In the formal project, first set World Settings → GameMode Override to /Game/Blueprints/Player/BP_ThirdPersonGameMode.
- Play and test zone by zone: A sight and cover, C hearing, B lights, E dark hall, D witness / body / alarm.
- Guards and lights already have debug drawing on, so cones, awareness bars and light circles show straight away.
- The key hints on the floor (L for lights, V for invisibility and so on) only work on a character with the Stealth Move Package. In the formal project, press F8 to leave the character and toggle a light's Visible instead.
How to check it worksWalk past the booth in zone C: sprinting makes the guard turn and investigate, crouching doesn't.