Home▸Game Development▸Field of View (2D) — Shadow-Casting Visibility Polygon

👁️ Field of View (2D) — Shadow-Casting Visibility Polygon

Interactive 2D top-down field-of-view simulator. Cast rays across an NPC's vision cone toward every obstacle corner, trim each ray at the nearest wall, and build the exact visibility polygon in real time.

Game Development2DModerate60 FPS📱 Mobile-adapted⇄ 3D version
2d-field-of-view ↗ Open standalone
⚙ Under the hood

A top-down 2D field-of-view simulator. It casts rays from an NPC toward every obstacle corner inside its vision cone, stops each ray at the first wall it hits, and connects the ordered hit points into a precise visibility polygon. Adjust the field-of-view angle and view distance, drag the NPC to aim it, and draw or move rectangular walls to watch the polygon update and see when the target enters its sight.

game-airaycastingvisibility-polygonstealthshadow-castingline-of-sight

2D · HTML5 Canvas 2D · 60 FPS target · runs fully client-side, no install

What did you find?

Add reproduction steps (optional)