Camera Mode: Onboard
Vehicle-mounted camera that follows a specific node position with configurable rotation and offset. Used for cockpit, hood, bumper, and other vehicle-attached views.
Vehicle-mounted camera that follows a specific node position with configurable rotation and offset. Used for cockpit, hood, bumper, and other vehicle-attached views.
Overview
The onboard camera reads a node position from the vehicle mesh, orients itself using reference nodes (ref/left/back), and allows the player to freely rotate the view. Includes manual zoom via the manualzoom component. The special "driver" camera name is hidden from the user but its data is used by other camera modes.
Class Properties
| Property | Type | Default | Description |
|---|---|---|---|
canRotate | bool | true | Whether player can rotate the view (jbeam-configurable) |
camNodeID | number | refNodes.ref | Node ID for camera position |
camRot | vec3 | vec3() | Current Euler rotation (yaw, pitch) |
offset | table | nil | {x, y, z} offset in vehicle-local space |
rotation | table | nil | Fixed rotation override from jbeam |
idUp | number | nil | Optional custom up-reference node |
idBack | number | nil | Optional custom back-reference node |
idRef | number | nil | Optional custom ref node for orientation |
Methods
| Method | Signature | Description |
|---|---|---|
init | C:init() | Set up manualzoom, load config, reset |
onVehicleCameraConfigChanged | C:onVehicleCameraConfigChanged() | Mark "driver" cam as hidden |
reset | C:reset() | Reset rotation and zoom |
update | C:update(data) | Compute position/rotation from nodes |
setRefNodes | C:setRefNodes(center, left, back) | Set reference node IDs |
Node-Based Orientation
-- Build camera coordinate frame from vehicle nodes
ref:set(data.veh:getNodePositionXYZ(self.camNodeID))
up:set(data.veh:getNodePositionXYZ(self.idUp))
back:set(data.veh:getNodePositionXYZ(self.idBack))
dir:setSub2(ref, back); dir:normalize()
camLeft:setCross(dir, camUp); camLeft:normalize()
camUp:setCross(camLeft, dir); camUp:normalize()Vehicle-Local Offset
-- Apply offset in vehicle-local coordinate frame
if type(self.offset) == 'table' then
nodePos = nodePos + dir * self.offset.x
- camLeft * self.offset.y
+ camUp * self.offset.z
endLook-Back Support
-- Look-back uses rear spawn point instead of node position
if data.lookBack then
qdir = rotateEuler(math.rad(180), 0, rollAngle, qdir)
data.res.pos:set(data.veh:getSpawnWorldOOBBRearPoint())
endKey Notes
- Player rotation reads
MoveManager.yawRelative/pitchRelative+ held keys - Pitch clamped to ±85° unless
self.rotation.zis set (full gimbal) "driver"named camera is hidden but provides data for other camera modes- Uses
rotateEulerhelper for composing yaw/pitch/roll rotations
See Also
- Camera Mode: Autopoint - Related reference
- Camera Mode: Autozoom - Related reference
- Camera Mode: Big Map - Related reference
- Core Systems Guide - Guide
Camera Mode: Observer
Global camera mode that uses scene-placed camera objects to view the action. Supports bullet-time speed control, position blending, and target override for cinematic scenario cameras.
Camera Mode: Orbit
The primary third-person vehicle camera. Orbits around the vehicle with mouse/gamepad rotation, dynamic FOV (dolly zoom), dynamic pitch, collision avoidance, and smooth relaxation-based auto-tracking.