Camera Mode: Top Down
Example custom camera mode providing a top-down overhead view of the vehicle. Height and look-ahead scale with vehicle speed.
Example custom camera mode providing a top-down overhead view of the vehicle. Height and look-ahead scale with vehicle speed.
Overview
A simple camera mode that positions itself directly above the vehicle, looking straight down. The camera height increases with speed, and the look-at point shifts forward based on velocity. Serves as a documented example of how to create custom camera modes.
Class Properties
| Property | Type | Default | Description |
|---|---|---|---|
disabledByDefault | bool | true | Must be enabled in settings |
fov | number | 20 | Narrow FOV for overhead view |
vel | number | 0 | Smoothed velocity magnitude |
veloSmoother | ExponentialSmoothing | - | Velocity smoothing (factor 50) |
Methods
| Method | Signature | Description |
|---|---|---|
init | C:init() | Set up velocity smoother |
onVehicleCameraConfigChanged | C:onVehicleCameraConfigChanged() | Set default FOV |
update | C:update(data) | Compute overhead position from speed |
setRefNodes | C:setRefNodes(center, left, back) | Set reference nodes |
Height & Look-Ahead Calculation
-- Smooth velocity to avoid camera jitter
self.vel = self.veloSmoother:get(
(self.lastDataPos - data.pos):z0():length() / data.dtSim
)
-- Look-ahead based on speed (max 10 units forward)
local targetPos = data.pos + dir:z0():normalized() * math.min(10, 0.5 * self.vel)
-- Camera height scales with speed
local camPos = targetPos + vec3(0, 0, (self.vel * 0.9) + 50)Key Notes
- Uses manual velocity calculation (position delta / dt) instead of
data.vel - Velocity is smoothed with
newExponentialSmoothing(50, 1)to prevent spikes - Minimum height is 50 units; scales up with speed (50 + vel × 0.9)
- Narrow 20° FOV gives a zoomed-in satellite view
- Good reference for building custom camera modes
See Also
- Camera Mode: Autopoint - Related reference
- Camera Mode: Autozoom - Related reference
- Camera Mode: Big Map - Related reference
- Core Systems Guide - Guide
Camera Mode: Smooth
Spring-based position smoothing filter. Applies temporal spring smoothing independently to each axis of the camera position to reduce jitter and sudden jumps.
Camera Mode: TrackIR
Global filter that integrates TrackIR head-tracking hardware. Translates and rotates the camera based on the player's physical head position and orientation.