Stealth DetectionCombat

Enemies have multi-state awareness of the player; avoidance rather than engagement is the primary success condition.

Metal Gear-style box stealth: the box hides you, but lift it while the guard faces the lane and you're spotted, move only while it looks away to reach the exit.

How stealth detection works in Godot

RayCast2Dnode

Line of sight. Cast from the guard toward the player; a clear ray (nothing solid in the way) means the player is potentially seen.

$Sight.target_position = to_local(player.global_position)
if $Sight.is_colliding() and $Sight.get_collider() == player:
    raise_awareness(delta)

Area2Dnode

Hearing radius. An Area2D around the guard catches noise events: running or gunfire inside it nudges awareness even with no line of sight.

func _on_noise_entered(src):
    awareness += src.loudness

enumprimitive

Awareness as discrete states (UNAWARE / SUSPICIOUS / ALERT). Sight and sound push a meter; crossing thresholds flips the state and the guard's behavior.

enum Awareness { UNAWARE, SUSPICIOUS, ALERT }
if meter > 80: state = Awareness.ALERT

In short: Detection state machine (UNAWARE / SUSPICIOUS / ALERT) per enemy; RayCast2D for sight lines; Area2D for sound radius

Retro games that use stealth detection

4 catalogued game(s) use this mechanic, spanning 1987–2000.

Related combat mechanics

▶ Explore Stealth Detection interactively: see every game + the Godot system