Multiseat Camera
Automatic camera system for multiseat mode. Calculates a shared camera view that encompasses all player vehicles by averaging positions and adjusting distance/FOV dynamically.
Automatic camera system for multiseat mode. Calculates a shared camera view that encompasses all player vehicles by averaging positions and adjusting distance/FOV dynamically.
Public Functions
| Function | Signature | Description |
|---|---|---|
M.onUpdate | () | Updates camera to frame all player vehicles (nop when disabled) |
M.onSettingsChanged | () | Enables/disables based on multiseat setting |
M.onSerialize | () | Disables multiseat camera before serialization |
Camera Algorithm
Each frame when enabled:
- Average position - Computes mean position of all player vehicles
- Max distance - Finds the farthest vehicle from the mean, doubles it + 10m padding
- Direction - Derived from frame-to-frame position delta
- Apply - Sets camera target, distance, FOV (40°), and reference frame via
core_camera
Camera Settings Applied
| Setting | Value | Description |
|---|---|---|
| Target mode | "notCenter" | Offset target mode |
| Distance | maxDistance | Dynamic based on vehicle spread |
| Max distance | math.huge | No upper limit |
| FOV | 40 | Fixed narrow field of view |
| Reference | targetCenter, left, back | Computed orientation vectors |
Usage Example
-- Multiseat camera is controlled by the "multiseat" setting
-- It activates/deactivates automatically via onSettingsChanged
-- Manual control (internal):
-- setEnabled(true) -- activates camera and hooks onUpdate
-- setEnabled(false) -- resets all vehicle cameras to defaultEnable/Disable Behavior
- On enable: Resets camera for player 0's vehicle, begins tracking
- On disable: Resets camera configuration and per-vehicle references for all vehicles
- On serialize: Auto-disables to prevent stale state
Notes
- Uses
core_input_bindings.getAssignedPlayers()to determine which players have vehicles. - Camera follows the mean position with a smooth direction vector.
- The
onUpdatefunction is swapped betweennopand the real implementation viasetEnabled. - Requires
core_camerato be loaded.
See Also
Multiseat
Local multiplayer input assignment. Maps input devices (keyboards, gamepads) to player slots and seats players into vehicles. Supports up to 64 simultaneous players.
Multi Spawn
Spawns groups of vehicles in configurable formations (road, grid, line). Handles vehicle selection from installed data with population-weighted randomization, paint assignment, and formation placement