Mirror Multiplayer Vehicle
Synchronizes vehicle state over Mirror.
Overview
MirrorMultiplayerVehicle handles state synchronization for vehicle inputs, lights, and engine RPM. It does NOT synchronize physics - add NetworkTransformReliable or NetworkRigidbodyReliable for position/rotation/velocity sync.
Synchronized State
Updates at 20Hz (configurable via SYNC_INTERVAL constant):
Inputs:
- Steering (-1 to 1)
- Throttle, clutch, handbrake (0 to 1)
- Shift commands (shiftInto, shiftUp, shiftDown)
Flags:
- Engine start/stop
- Horn, boost, flip-over
- Trailer attach/detach
- Cruise control
Visual/Audio:
- Light states (bit-packed integer)
- Engine angular velocity (for RPM display/sound)
Network Flow
Client-owned vehicle:
- Local input drives VehicleController
GetMultiplayerState()captures current state- Sends via
CmdMultiplayerState()to server - Server validates and broadcasts via
RpcMultiplayerState()
Server-hosted vehicle:
- Server input drives VehicleController
- Broadcasts state directly via
RpcMultiplayerState()
Remote clients:
- Receive state via RPC
SetMultiplayerState()applies to VehicleControllerautoSetInputdisabled to prevent local input override
Setup
See the Mirror multiplayer setup guide for integration instructions.