Mirror
NWH Vehicle Physics 2 multiplayer setup with Mirror.
Requirements
- Mirror networking package installed
- Vehicle already set up for single-player
Install Mirror first. The sample compiles only when Mirror is present (its asmdef is gated on the
MIRRORdefine, which Mirror sets automatically). Import the sample before installing Mirror andMirrorMultiplayerVehiclewon't appear.
Import Sample
- Open Package Manager (Window > Package Manager)
- Select "NWH Vehicle Physics 2" from the list
- Navigate to the Samples tab
- Import "Multiplayer Mirror Sample"
Scene Setup
Create a NetworkManager GameObject:
- Add
NetworkManagercomponent - Add
NetworkManagerHUDcomponent (for testing) - Add
KcpTransportcomponent (or other transport)
Vehicle Setup
- Add
MirrorMultiplayerVehiclecomponent to your vehicle- This automatically adds required
NetworkIdentitycomponent
- This automatically adds required
- Add ONE physics sync component:
NetworkTransformReliable- syncs position/rotation onlyNetworkRigidbodyReliable- syncs full physics state (recommended)
- Save vehicle as prefab
- Assign prefab to NetworkManager's Player Prefab field
How It Works
MirrorMultiplayerVehicle synchronizes vehicle state at 20Hz:
- Inputs (steering, throttle, clutch, handbrake)
- Gear shifts
- Light states
- Engine RPM
Physics (position/rotation/velocity) are handled by Mirror's NetworkTransform/NetworkRigidbody components.
Works in both dedicated server and host+client modes.