Guide

Game enemy vision cone and line of sight systems explained

Harbor Siege's Bastion infiltration level shipped with guards that used oversized box trigger volumes labeled “vision.” Playtesters were spotted through a one-inch gap between two crates, then walked directly in front of a sentry at ten meters without reaction. Stealth felt random: unfair when caught, boring when ignored. Analytics showed 62% of players abandoned the mission after the third inexplicable alarm.

The refactor replaced trigger volumes with a vision cone and line-of-sight (LOS) system: horizontal field-of-view angles, vertical sight bands, multi-sample occlusion raycasts, peripheral versus central detection rates, and a graded suspicion meter that feeds the same alert pipeline as footstep noise. False alarms dropped 71%; intentional stealth routes became readable. This guide covers vision detection taxonomy, FOV geometry, LOS and occlusion, distance and lighting modifiers, alert state machines, memory and last-known-position, multiplayer authority, the Harbor Siege infiltration refactor, a technique decision table versus trigger volumes only, pitfalls, and a production checklist.

Vision detection taxonomy

Not every game needs photorealistic eyes. Pick a detection model that matches genre pacing and player literacy.

Model Behavior Best for
Binary instant Inside cone + clear LOS = full alert immediately Arcade stealth, horde modes, low-stakes infiltration
Graded suspicion Peripheral sight fills a meter; central sight fills faster Immersive sims, tactical stealth, MGS-style pacing
Peripheral + central split Wide low-acuity cone + narrow high-acuity cone Action-stealth hybrids where players need readable feedback
Omnidirectional sensor 360° vision with short range (drones, turrets) Security devices complementing human patrols
Screen-space / awareness bubble Abstract radius without facing; cheap but opaque RTS, RPG overworld, non-stealth combat awareness

Vision almost always pairs with hearing in AI perception stacks. Document which sense wins when both fire and whether vision overrides noise-based investigation.

Field of view geometry

A vision cone is not a single frustum drawn for debug only — it is the query shape your perception tick evaluates each frame or at a fixed interval.

  • Horizontal angle. Human peripheral vision is roughly 180° but useful discrimination is closer to 120°. Stealth games often use 90° central + 45° peripheral extensions, or a single 110° cone for guards and 70° for elites.
  • Vertical band. Ignore targets above or below the head-forward vector beyond a pitch limit (typically ±30°) so players on catwalks are not spotted through floor geometry errors.
  • Near blind spot. Some designs zero detection inside 1–2 meters directly ahead — mimicking focus on middle distance and preventing “face-hugger” exploits.
  • Height origin. Raycast from eye socket bone, not capsule center; crouched players shrink effective silhouette height.
  • Turn rate coupling. If the guard is mid-turn, widen the cone temporarily or delay sight checks until facing settles — avoids snap-spotting when animation and logic desync.

Expose cone parameters per archetype in data tables so level designers tuning patrol routes know what each guard class can see at corridor intersections.

Line of sight and occlusion

Being inside the cone is necessary but not sufficient. LOS confirms nothing opaque blocks the view between eye and target.

  • Raycast samples. Cast from eyes to target head, chest, and feet. Require one or two hits on valid visibility bones depending on strictness. Partial cover should hide feet while leaving head exposed for skillful peeks.
  • Collision layers. Dedicated VisionBlocker layer for world geo; exclude glass, chain-link fences, and foliage that should be see-through or semi-transparent to vision.
  • Thin geometry. Merge adjacent crate colliders or use thicker occluders — single-triangle gaps cause the Harbor Siege crate-gap spotting bug.
  • Dynamic occluders. Closing doors, moving platforms, and destructible walls must update blocker state; cache invalidation on open/close events.
  • Performance. Broadphase with cone frustum culling before raycasts; stagger checks across frames for crowds (every 3rd guard per tick at 20 Hz perception).

Debug-draw LOS lines in editor play mode. If designers cannot see why a guard spotted the player, players will not learn either.

Distance, lighting, and stance modifiers

Raw cone + LOS is the baseline. Modifiers make stealth readable and tunable without rewriting geometry.

Modifier Effect Design note
Distance falloff Detection rate drops beyond effective sight range Pair with LOD: far enemies use cheaper bubble checks
Light level Dark zones reduce fill rate; bright zones increase it Show light/shadow on minimap or use visible light pools
Player stance Crouch/prone shrinks visible bone set and detection multiplier Must match animation capsule changes
Movement speed Sprinting raises silhouette motion salience Stacks with noise; do not double-punish without telegraph
Disguise / faction Valid uniform delays or prevents suspicion fill Requires fail conditions (wrong zone, running, weapons out)

Publish modifier values in internal docs. When playtesters ask “why did he see me?” support needs a single chart, not engineer archaeology.

Alert state machine

Vision should feed a shared alert pipeline used by noise, damage, and buddy pings. Typical states:

  1. Unaware. Patrol or idle; vision checks at base rate.
  2. Suspicious. Peripheral sight or brief LOS; guard turns toward stimulus, may investigate last noise.
  3. Alerted / searching. Central LOS held long enough; guard moves to last-known-position, calls backup.
  4. Combat. Confirmed hostile; vision cone widens, LOS checks accelerate, leash to encounter zone may break.

Use separate timers for acquire (entering suspicion) and confirm (entering combat). Players need a window to break LOS after a partial spot. UI feedback — filling eye icon, escalating music stinger, guard VO — must match meter fill rates exactly.

For stealth design pillars, document whether combat is fail-state or recoverable. Harbor Siege uses graded failure: first alert spawns reinforcements slowly; full combat wave only after ten seconds of confirmed sight.

Memory and last-known-position

When LOS breaks, guards should not instantly forget the player.

  • Last-known-position (LKP). Store world coordinates and timestamp at last central sight; search behavior pathfinds to LKP plus expanding radius.
  • Decay. Suspicion meter drains when LOS is lost; drain rate slower in alerted state than suspicious.
  • Shared awareness. Radio call shares LKP to nearby guards; cap propagation range to prevent map-wide alarm from one peek.
  • False LKP. Throwables and holograms can seed decoy LKPs if your design supports misdirection.

Stale LKP older than 30–60 seconds should downgrade alert state unless another sense re-acquires the target.

Multiplayer authority

Co-op stealth breaks if each client runs independent vision dice rolls.

  • Server-authoritative perception. Host or dedicated server runs sight checks; clients receive alert state replication only.
  • Target selection. Define whether any visible squad member triggers sight or only the closest / most exposed player.
  • Latency compensation. Do not rewind full physics; slight grace on breaking LOS (100–150 ms) reduces “I was behind cover on my screen” disputes.
  • Debug replay. Log cone parameters, raycast hits, and meter fill per alert for post-session review.

Harbor Siege infiltration refactor

Harbor Siege replaced Bastion trigger volumes with a layered vision stack:

  • Standard guard: 110° horizontal cone, 18 m range, 0.4 s central sight to confirm combat, 1.2 s peripheral to reach suspicious.
  • Triple raycast LOS (head, chest, pelvis); two-of-three required for sight credit; crate colliders merged to 4 cm minimum thickness.
  • Light zones tagged in level data; shadow tiles apply 0.55× detection fill rate with visible floor decal for player learning.
  • Crouch stance removes pelvis sample from enemy query list and applies 0.7× fill multiplier.
  • Suspicion meter replicated to UI; audio stinger at 50% and 90% fill.
  • Alert radio propagates LKP to guards within 25 m, not entire map.
  • Security cameras use fixed 70° cones with no peripheral grace — complements human patrols documented in the surveillance systems guide.

Mission abandon rate fell from 62% to 19% in week-one telemetry. Average retry count dropped from 4.1 to 2.3. Player surveys cited “I understood why I was seen” as the top improvement.

Technique decision table

Scenario Trigger volumes only Vision cone + LOS
Stealth-heavy mission with patrol routes Opaque, unfair edge cases Preferred — readable skill expression
Horde survival with back-spawn awareness Acceptable behind-player volumes Often overkill; use short-radius bubble
Open-world RPG enemy acquisition Too expensive to tune per NPC Hybrid: bubble + LOS only in stealth zones
Competitive PvP vision Not applicable Server LOS with lag compensation required
Prototype vertical slice Fast placeholder Plan migration before polish pass
Top-down tactics Tile visibility grids work well 3D cone optional; grid LOS is simpler

Common pitfalls

  • Eye height at capsule center. Guards spot over walls that art suggests block vision.
  • Single-ray LOS. One chest hit fails when player crouches behind low cover.
  • Instant combat on peripheral touch. No room for player recovery or learning.
  • Mismatched debug cone. Designer gizmo shows 90°; runtime uses 120°.
  • Ignoring vertical FOV. Players on ladders spotted through floors.
  • Global alarm chains. One peek alerts every guard on the map.
  • No suspicion decay. Guards stare at empty corners forever.
  • Vision without feedback. Players cannot tell fill rate or break-LOS timing.

Production checklist

  • Vision detection taxonomy chosen per enemy archetype and documented.
  • Horizontal and vertical FOV angles defined in data tables per class.
  • Multi-sample LOS raycasts with correct collision layers and bone targets.
  • Thin geometry audit on stealth-heavy levels; occluder thickness minimum enforced.
  • Distance, lighting, and stance modifiers exposed to designers with in-editor preview.
  • Alert state machine shared across vision, noise, and damage stimuli.
  • Separate acquire and confirm timers with UI/audio feedback tied to meter fill.
  • LKP memory, search behavior, and suspicion decay tuned per mission stakes.
  • Radio propagation range capped; no map-wide alert from single event.
  • Multiplayer: server-authoritative sight checks and replicated alert state.
  • Debug visualization for cone, rays, and meter fill in development builds.
  • Playtest script: peek, crouch-pass, sprint-expose, break-LOS, and co-op simultaneous expose.

Key takeaways

  • Vision is geometry plus policy. Cones define where to look; LOS defines what can be seen; meters define how fast alerts escalate.
  • Graded suspicion beats binary triggers. Players learn when they are at risk versus already caught.
  • Occlusion quality is level quality. Merge thin colliders and sample multiple bones.
  • Pair sight with sound. Noise investigation and vision confirmation should share one alert brain.
  • Feedback is mandatory. If players cannot read the cone, stealth feels like RNG.

Related reading