Integration: Mirror Networking

Table of Contents

Mirror is a free, open-source networking library for Unity. RCCP provides an integration package that enables multiplayer vehicle synchronization using Mirror's networking framework. This guide covers installation, setup, and usage.


Overview

The RCCP Mirror integration follows the same design philosophy as the Photon integration: the vehicle owner sends its state (inputs, drivetrain, lights, transform) to all other clients, and remote clients apply that state with interpolation. Mirror uses a server-authoritative or host model, where one player acts as both server and client (host mode) or a dedicated server relays data.

Mirror is a suitable choice when you want:


Prerequisites

  1. Mirror installed in your project. Download it from the Unity Asset Store (free).
  2. Realistic Car Controller Pro installed and working with at least one vehicle.

Installing

Step 1: Import Mirror

If Mirror is not yet in your project, import it from the Asset Store. After import, the MIRROR scripting symbol is added automatically by Mirror.

Step 2: Import the RCCP Integration Package

  1. Open the RCCP Welcome Window: Tools > BoneCracker Games > Realistic Car Controller Pro > Welcome Window.
  2. Navigate to the Addons tab.
  3. Under Mirror, click Import Mirror Integration.
  4. Unity imports RCCP_MirrorIntegration.unitypackage from Addons/Installers/.
  5. Wait for Unity to recompile.

The integration files are installed to:


Assets/Realistic Car Controller Pro/Addons/Installed/Mirror/

Step 3: Verify Scripting Symbols

After import, the RCCP_MIRROR scripting symbol is added automatically by RCCP_AddonDefineManager. Both MIRROR (from Mirror) and RCCP_MIRROR (from the integration) must be present.


Scripting Symbols

SymbolSourceRequired
MIRRORMirror package (automatic)Yes
RCCP_MIRRORRCCP Mirror integration (automatic via RCCP_AddonDefineManager)Yes

Setting Up a Networked Vehicle

Step 1: Start with a Working RCCP Vehicle

Ensure your vehicle works correctly in single-player before adding networking. See Vehicle Setup.

Step 2: Add NetworkIdentity

  1. Select your vehicle prefab.
  2. Add Component: NetworkIdentity.
  3. This is required by Mirror for all networked objects.

Step 3: Add the RCCP Mirror Sync Component

  1. Add the RCCP Mirror synchronization component (provided in the integration package) to your vehicle.
  2. This component handles serialization of vehicle state across the network, similar to RCCP_PhotonSync in the Photon integration.

Step 4: Register as a Spawnable Prefab

  1. Open your scene's NetworkManager component.
  2. In the Registered Spawnable Prefabs list, add your RCCP vehicle prefab.
  3. This allows Mirror to instantiate the vehicle on remote clients.

Step 5: Spawn and Register

On the server or host, spawn the vehicle using Mirror's API:


GameObject vehicleObj = Instantiate(vehiclePrefab, spawnPosition, spawnRotation);
NetworkServer.Spawn(vehicleObj, connectionToClient);

RCCP_CarController vehicle = vehicleObj.GetComponent<RCCP_CarController>();
RCCP.RegisterPlayerVehicle(vehicle);
RCCP.SetControl(vehicle, true);

On each client, after the vehicle is spawned, check isLocalPlayer or isOwned to determine whether to enable local input or apply remote synchronization.


Vehicle Synchronization

The RCCP Mirror sync component follows the same pattern as the Photon sync:

Owner (Local Player)

Remote (Other Players)

Synchronized Data

The integration synchronizes the same data categories as the Photon integration:

CategoryFields
Inputsthrottle, brake, steer, handbrake, NOS boost, clutch
EngineRPM, starting flag, running flag
Gearboxcurrent gear, gear input, gear state, shifting flag
Differentialleft and right output for each differential
Lightslow beam, high beam, left indicator, right indicator, hazards
WheelsRPM for each wheel collider
Transformposition, rotation, linear velocity, angular velocity

Authority Model

Mirror supports two authority models. The RCCP integration can work with either:

Server-Authoritative (Recommended)

Client-Authoritative

To configure authority, use Mirror's [ClientAuthority] attribute on sync variables or use [Command] methods for server-authoritative input processing.


Network Manager Setup

A typical Mirror setup for RCCP requires:

  1. NetworkManager -- Add to a persistent GameObject in your starting scene. Configure:
  1. NetworkManagerHUD (optional) -- Add alongside NetworkManager for quick testing. Provides Host, Client, and Server buttons.

Common Issues

Remote vehicles desync or jitter

Authority errors ("not the owner")

Vehicle spawns but does not respond to input

Compile errors after import

High bandwidth usage


Removing the Integration

  1. Delete the folder: Assets/Realistic Car Controller Pro/Addons/Installed/Mirror/.
  2. Remove the RCCP_MIRROR scripting symbol from Edit > Project Settings > Player > Scripting Define Symbols (or let RCCP_AddonDefineManager handle it automatically).
  3. Wait for Unity to recompile.

Comparison: Mirror vs. Photon

FeatureMirrorPhoton PUN 2
CostFree, open-sourceFree tier (20 CCU), paid tiers for more
HostingSelf-hosted or dedicated serverPhoton Cloud (managed)
AuthorityServer-authoritative by defaultOwner-authoritative (client sends state)
TransportPluggable (KCP, Telepathy, Steam, etc.)Photon proprietary
LAN SupportYes, built-inLimited (Photon Cloud only in free tier)
Ease of SetupModerate (requires server management)Easy (cloud-hosted, just need App ID)
ScalabilityDepends on server hardwareScales via Photon Cloud pricing tiers

See Also


Support: bonecrackergames@gmail.com | www.bonecrackergames.com

Need help? See Troubleshooting