NWH Vehicle Physics 2
Search Results for

    Show / Hide Table of Contents

    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:

    1. Local input drives VehicleController
    2. GetMultiplayerState() captures current state
    3. Sends via CmdMultiplayerState() to server
    4. Server validates and broadcasts via RpcMultiplayerState()

    Server-hosted vehicle:

    1. Server input drives VehicleController
    2. Broadcasts state directly via RpcMultiplayerState()

    Remote clients:

    1. Receive state via RPC
    2. SetMultiplayerState() applies to VehicleController
    3. autoSetInput disabled to prevent local input override

    Setup

    See the Mirror multiplayer setup guide for integration instructions.

    In this article
    Back to top Copyright © NWH - Vehicle Physics, Aerodynamics, Dynamic Water Physics