How-To: Prevent Camera Clipping (Penetration Avoidance)
Goal: stop the third-person camera from clipping through walls by pulling it in when geometry comes between it and the pawn, and control which actors it may pass through.
UCrimsonCameraMode_ThirdPerson subclass (Quick Start step 4). Penetration avoidance is on by default - this page is about tuning it and adding per-actor rules.1. It is on by default
UCrimsonCameraMode_ThirdPerson runs penetration avoidance every frame: it traces a fan of feelers from the pawn toward the camera and, if they hit, blends the boom in so the view never ends up inside geometry. bPreventPenetration (default true) is the master switch; PenetrationBlendInTime / PenetrationBlendOutTime shape how fast it pulls in and eases back out.
2. Tune the feelers
The fan is the mode's PenetrationAvoidanceFeelers array. Each FCrimsonPenetrationAvoidanceFeeler is one ray offset from the main line by AdjustmentRot, weighted by WorldWeight (how much a world hit pulls the camera) and PawnWeight (set to 0 so a feeler ignores pawns), with a trace Extent and a TraceInterval throttle.
PawnWeight = 0 never collides with pawns, so other characters don't shove your camera around. Keep at least one full-weight central feeler for solid world geometry.3. Let the camera pass through specific actors
Implement ICrimsonCameraAssistInterface on your Character or Controller to feed the trace an ignore-list (the pawn, a mount, a vehicle) and, optionally, to react when the camera is forced inside the focal target.
See also
- How-To: Fade Occluding Geometry - fade walls instead of (or alongside) pulling the camera in.
- Concept: The Mode Stack & Blending - where penetration avoidance runs in the view pipeline.