Unity Stealth AI: Crouching to Break Line of Sight
Watch a crouching player lower the visibility sample used by a Unity guard so half-height cover cleanly blocks line of sight without changing colliders.
What this clip demonstrates
- Standing and crouching can expose different visibility sample heights.
- Existing cover geometry performs the occlusion work.
- The player controller only needs to publish the current posture.
Implementation notes
Testing visibility against the character pivot often produces unfair results because the pivot stays near the feet while the visible body changes height. A dedicated visibility sample lets the stealth controller describe the posture that the guard should try to see.
In this clip the crouch state lowers that sample behind a half wall. The guard ray then hits the wall before it reaches the player, so sight is lost for a reason that matches the image on screen. No animation-specific coupling or extra crouch collider is required.
Build the underlying mechanic
Design reliable enemy vision in Unity with field-of-view checks, line-of-sight occlusion, focused and peripheral cones, awareness buildup, and fair loss of sight.
Read: Enemy vision and line of sight