Building Realistic Stealth Detection Cones in Games

Realistic stealth gameplay relies on believable enemy artificial intelligence (AI) that reacts dynamically to visual and auditory cues in the game world. This article explores the core technical and design approaches developers use to construct realistic stealth detection cones, focusing on how visual fields of view, dynamic lighting conditions, and acoustic propagation systems intersect to create fair and immersive stealth mechanics.

Geometric Vision Cones and Raycasting

The foundation of a visual stealth system is the Field of View (FOV) cone. Game designers implement this using a combination of mathematical volume checks and line-of-sight raycasting.

  • Angular and Distance Thresholds: The AI calculates the dot product between its forward facing vector and the vector toward the player to determine if the target falls within a defined angle (typically between 60 and 120 degrees) and maximum view distance.
  • Line-of-Sight Occlusion: If the player is within the cone volume, the engine casts physics rays from the AI's eye position to critical bones on the player model (head, torso, feet). If an obstacle blocks all rays, detection does not occur, preventing detection through walls or solid cover.
  • Multi-Tiered Vision Zones: Realistic systems divide the vision cone into distinct zones:
    • Peripheral Zone: Wide angle, shorter range, slow detection rate.
    • Central/Focused Zone: Narrow angle, long range, rapid detection rate.
    • Immediate Proximity Sphere: A small radius around the AI where presence is felt regardless of angle.

Light Level Integration

Static vision cones often feel artificial because real human vision adapts to environmental illumination. Modern stealth mechanics dynamically modify detection parameters based on the amount of light cast upon the player.

  • Light Probe and Render Target Sampling: Designers sample the light intensity at the player's world position using light probes or a small secondary camera rendering the player's silhouette against a black background. The calculated luminosity scalar directly scales the AI's detection parameters.
  • Dynamic Cone Scaling: In dark environments, the AI's visual cone distance and angle shrink, or the time-to-detect meter fills significantly slower. In bright light, the cone expands to its maximum limits, making detection nearly instantaneous at standard ranges.
  • Shadow Buffers and Volume Tracing: Advanced engines evaluate whether the player intersects with dynamic shadow maps, allowing the player to hide within moving shadows cast by geometry or dynamic searchlights.

Auditory Propagation and Acoustic Cones

Noise functions as an omnidirectional or directional trigger that complements the vision system. Unlike sight, sound does not rely solely on direct line-of-sight.

  • Radial Noise Spheres: Basic actions (walking, sprinting, crouch-moving, firing weapons) emit sound spheres with specific radii. If an AI is within this radius, it registers the noise event.
  • Acoustic Raycasting and Pathfinding: To simulate realistic sound travel, advanced systems route sound along the shortest path on the navigation mesh (NavMesh) or use audio raycasts to account for wall dampening and open doorways.
  • Directional Audio Awareness: When a sound is heard, the AI does not instantly spot the player; instead, it interpolates its head or body toward the sound origin. This swings the visual detection cone directly toward the disturbance, bridging the auditory and visual systems.

Awareness Meters and Alert States

To prevent frustrating "binary" detection where players are instantly spotted or ignored, systems combine light and noise data into an incremental awareness value.

  • Accumulative Detection Rate: Detection is represented as a floating-point value from 0 to 100%. The speed at which this fills is governed by the formula:
    Detection Rate = Base Rate * Distance Factor * Light Level * Stance Modifier
  • AI State Transitions: As the awareness meter rises, the AI transitions smoothly through states:
    • Unaware (0%): Standard patrol routine.
    • Suspicious (1%–99%): Pauses, investigates anomalies, turns vision cone toward stimuli.
    • Alert/Combat (100%): Engages the player, sounds alarms, and calls reinforcements.