API ReferenceGE ExtensionscorecameraModes
Camera Mode: Collision
Filter camera that prevents the camera from clipping through walls and terrain. Uses raycasting from target to camera with near-clip plane corner checks.
Filter camera that prevents the camera from clipping through walls and terrain. Uses raycasting from target to camera with near-clip plane corner checks.
Class API
| Method | Signature | Description |
|---|---|---|
C:init | () | Resets state, enables raycasting |
C:update | (data) | Moves camera closer if obstruction detected |
C:onVehicleSwitched | () | Re-initializes on vehicle switch |
C:collidingCamDistance | () | Returns colliding distance or nil if not colliding |
Properties
| Property | Type | Description |
|---|---|---|
isFilter | boolean | true - modifies camera position |
hidden | boolean | true - not user-selectable |
Collision Detection
- Near-clip plane corners: 4 parallel raycasts from target towards camera, offset by near-clip half-width/height
- Obstacle-in-front check: Tests if geometry intersects the near-clip plane rectangle
- Wall pass-through detection: Raycasts between previous and current near-clip center positions
Two Modes
- Raycast mode: Active when collisions detected; casts 4 rays from target to camera corners
- Passive mode: Only checks if obstacles appear in front of camera; re-enables raycast mode when found
Smoothing
- Camera pulls in instantly when hitting an obstacle
- Camera returns to normal distance gradually using
TemporalSmoothingNonLinear(1, 7)
Constants
| Constant | Value | Description |
|---|---|---|
safetyDistance | 0.1m | Extra pullback from hit point |
nearClipHalfWidth | 0.2m | Assumed near-clip plane half-width |
nearClipHalfHeight | 0.1m | Assumed near-clip plane half-height |
Usage Examples
-- Used internally by orbit/chase cameras
local collision = require('core/cameraModes/collision')()
collision:init()
-- Called each frame after main camera position is computed:
collision:update(data) -- modifies data.res.pos if collision detectedNotes
- Respects
settings.cameraCollisiontoggle - does nothing when disabled - Minimum collision distance is clamped to 0.5m to prevent camera inside vehicle
See Also
- Camera Mode: Autopoint - Related reference
- Camera Mode: Autozoom - Related reference
- Camera Mode: Big Map - Related reference
- Core Systems Guide - Guide
Camera Mode: Chase
Third-person chase camera that follows vehicle direction with automatic forward/backward switching. Features smoothed direction tracking, configurable roll smoothing, and collision detection.
Camera Mode: Crash
Cinematic crash camera with multiple viewpoints. Supports cockpit POV from the second vehicle, overhead close-up, and stationary observer positions.