Multiplayer
Goal: run the included networking example with two players, then prepare your own vehicle.
Before you start
Make sure that the vehicle works in single player. The RCCP 2 multiplayer integration uses Photon PUN 2:
| Integration | What you need | Included example |
|---|---|---|
| Photon PUN 2 | Photon PUN 2 installed and a configured Photon App ID. | Driving scene and a lobby with a room browser. |
Photon PUN 2 is separate from RCCP. RCCP supplies the vehicle integration and examples.
A local vehicle is the vehicle that your player controls. A remote vehicle is the vehicle of another player on your screen. Ownership sets which player sends the state of a vehicle.
Data shared between players
The RCCP2 Photon addon sends movement, wheel poses, engine RPM, throttle, brake, gears, engine state and lights. The owner runs the physics. Remote copies use kinematic Rigidbody components and disable the vehicle simulation.
The addon does not supply a complete multiplayer game:
- Damage, dents, repairs and detached parts are not synchronized.
- Paint, wheels, spoilers and other customization are not synchronized.
- Skidmarks, wheel smoke and sparks are not sent. Remote copies disable the components that make these effects.
- Replay playback does not start during a networking session.
If your game needs shared damage, shared customization or ownership changes between character and vehicle, write additional networking code.
Configure multiplayer with Photon PUN 2
1. Install the integration
- Install Photon PUN 2 and complete its App ID configuration.
- Open Tools > BoneCracker Games > Realistic Car Controller Pro 2 > Welcome Window.
- Select Addons > Photon PUN 2 > Import Integration.
- Wait until Unity finishes the import and compiles the scripts.
If the card shows Get Photon PUN 2, RCCP does not detect Photon yet. Finish the Photon installation before you import the integration.
Check: the Demos tab shows Lobby Photon and Blank Photon.
2. Test the supplied scenes
- Open Lobby Photon from the Demos tab.
- Make sure that Photon PUN 2 has your App ID.
- Before you build, add the lobby scene and its gameplay scene to the scene list of the build.
- Run two copies of the game. For example, run one build and one Editor session.
- Join the same room and drive on each copy.
Check: each player controls a different vehicle and sees the other vehicle move. On both copies, examine steering, braking and lights.
Blank Photon is the simpler gameplay example. The installed scenes are in Assets/Realistic Car Controller Pro 2/Addons/Installed/Photon PUN 2/Scenes/.
3. Prepare your own vehicle
- Stop Play Mode.
- In the Project window, select a vehicle prefab that drives correctly. The prefab root must have RCCP_CarController. The prefab must not have a PhotonView.
- Select Tools > BoneCracker Games > Realistic Car Controller Pro 2 > Photon PUN 2 > Create Network Variant.
- Save the variant directly in a Resources folder. Use a unique name.
- Add the variant to Vehicles on the demo spawner of the driving scene.
- Save the scene and do the two-client test again.
The core demo UI also uses RCCP_DemoVehicles_Photon.asset or RCCP_Prototype_Photon.asset. If you use that UI without the supplied spawner, update these registries.
Check: both players can spawn the correct prefab. The supplied demo spawns by prefab name. If you put the prefab in a subfolder of Resources, change the spawn path in the code.
Optional: custom Photon spawning
After network creation, the demo registers the local vehicle, enables control and assigns the camera target.
For the calls, see API Reference and the installed RCCP_PhotonDemo.cs.
The spawner creates the replacement vehicle before it removes the previous locally owned vehicle.
The setup command adds RCCP2_PhotonVehicle and a PhotonView with fixed ownership and unreliable synchronization.
The view observes the sync component explicitly. For shared vehicle ownership, write additional game code.
Multiplayer test problems
| What you see | What to check |
|---|---|
| The Addons card still shows Get Photon PUN 2 | Install Photon PUN 2 first and correct the compilation errors. |
| Photon does not connect | Examine the App ID and the first networking error in the Console. |
| Photon cannot find the vehicle prefab | Examine the Resources location of the prefab and the name or path in the spawn call. |
| A spawned vehicle has no control or camera | Examine the ownership and the RCCP player registration. |
| A new player cannot see an existing vehicle | Test prefab registration and spawning on both copies. Include a late-join test. |
| Remote vehicles jump or lag | Examine the connection first. Then test the smoothing options below. |
| Damage or customization is different | The sync stream does not include these items. |
| Replay does not start | Leave the live networking session first. |
Optional: smooth remote movement
Keep the supplied settings for the first successful test. Then change one value at a time and watch a remote vehicle.
Interpolation blends toward the received positions. Extrapolation predicts movement during gaps between updates.
| Setting | What it controls |
|---|---|
| Teleport Distance | Clears the history when two consecutive snapshots differ by more than this distance. Default: 10 meters. |
| Interpolation Delay | Delays the remote presentation to absorb changes in packet timing. Default: 0.1 seconds. |
| Photon Send Rate / Serialization Rate | The lobby sets the connection rates to 30 sends and 20 snapshots per second. |
The Photon addon limits prediction to 0.1 seconds. Test starts, stops, turns and collisions under your target network conditions. Remote kinematic vehicles can give different collision results on each client.
Additional tests before production
Do the test again for these cases:
- A player joins late.
- A player disconnects.
- The host leaves.
- The scene changes.
A successful first connection does not test these cases.
The Welcome Window > Symbols tab shows the integration scripting symbols and warns about missing addon folders. Photon installation and RCCP integration installation are separate steps. Do not add symbols manually to hide an incomplete installation.
Next step
- Scenes and Spawning — learn how RCCP selects the player vehicle and camera.
- API Reference — find the calls for custom spawning code.
- Demo Content — get more example vehicles.