29 · AI · 2D and 3D

Line of sight and aggro

Enemies notice you only when they could really see you.

Enemies that know where you are through walls feel like cheaters. Real detection has three checks: are you close enough, are you inside the view cone, and is there a clear line from their eyes to you. Add an awareness meter that fills while you are seen, and stealth becomes possible.

←→↑↓ sneakL wall check on/offDrag to sneak

Try this: Sneak behind the walls past the guard. Then press L to switch off the wall check: it sees you through walls.

view conesight rayalert

Awareness 0%Times spotted 0

Sneak to the coin without filling the meter.

Prompt bit

Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.

Give enemies real line of sight: detect the player only within 8 units, inside a 90 degree cone and with an unblocked raycast from the eyes, then fill awareness over 0.5 s instead of alerting instantly, so brief glimpses never trigger aggro.

42 words · one sentence to paste as is

Where it's used

Common mistakes

Distance-only aggro (enemies see through walls), raycasting from the feet or into the player's own collider, checking every enemy every frame, and instant alerts that make stealth impossible.

Writing this with an AI assistant? See our best AI coding assistants for game developers.

Missing a concept? Request one.

Related concepts

New concepts, in your inbox.

One short email when we add new concepts, plus our weekly roundup of AI tools for game devs. Unsubscribe any time.