PUN Multiplayer Add-On
The PUN Multiplayer Add-On synchronizes Ultimate Character Controller characters, items, and supported scene objects with version 2 of the Photon Unity Network (PUN). It supplies the controller-specific networking layer; your project still owns its room, match, authority, and game rules.
Before you begin
The add-on is not a complete multiplayer template. You should be comfortable writing PUN game logic before integrating it; Photon provides a PUN introduction if you need to learn its room and networking concepts first.
PUN’s client-authoritative architecture lets the local client decide actions such as movement, firing, and spawning without validation by a central authoritative server. Account for that trust model when choosing it: it is better suited to cooperative or casual games than to competitive games that require server-side validation.
Start here
- Import the required packages and configure the demo.
- Complete the scene, character, and object setup.
- Use Troubleshooting when a client cannot join or a spawn, transform, or active state is not synchronized.
The written setup pages are complete workflows; the embedded videos are optional demonstrations rather than required navigation.
What the add-on supplies
| Area | Add-on responsibility | Project responsibility |
|---|---|---|
| Character ownership | Adds the PUN identity, controller bridge, locomotion handler, and character monitors required by a processed prefab. | Decide who may own or control a character and how ownership changes. |
| Player spawning | SpawnManagerBase and the default SingleCharacterSpawnManager select and instantiate a registered character prefab. |
Create rooms, store player selection, and make custom prefab selection deterministic on every client. |
| Network object pooling | PunObjectPool creates and synchronizes registered projectiles, grenades, pickups, and other supported spawned prefabs. |
Register every network-owned prefab and decide which effects remain local presentation. |
| Scene identity | PunObjectIdentifier gives supported scene and collider objects stable identities for network messages. |
Rerun setup after hierarchy or collider changes and save the identifiers in the scene or prefab. |
| State and item mapping | PunStateManager supplies supported late-join state; ItemTypeTracker maps item identifiers consistently. |
Keep matching assets on every client and define any additional authoritative join snapshot. |
| Session rules | Uses PUN room and player state supplied by the project. | Implement lobby, matchmaking, teams, scoring, validation, reconnects, host behavior, and persistence. |
Implement a real two-client scenario
- Build and verify one local Ultimate Character Controller character before adding PUN components.
- Complete Scene Setup and Character Setup, then assign the processed prefab to the Spawn Manager.
- Create and join a room through project-owned PUN code. Verify one local input and camera owner; the other character instance must remain remote-controlled.
- Move, start one ordinary ability, equip one item, fire once, take one hit, die, and respawn. Confirm each gameplay result occurs once and observers receive the same state.
- Process and register one runtime object through Object Setup. Confirm spawn and destruction from a second client.
- Join a third client after state has changed and verify the character, item, health, and persistent object state that the game promises to late joiners.
Test a development build as well as multiple Editor instances. Build scenes, compile symbols, registered prefabs, and Photon App settings can differ even when a local Editor test succeeds.
Runtime API boundary
Use Photon PUN APIs for connections, rooms, player properties, ownership, and RPC or event transport. Use the add-on’s processed components for controller-specific replication; do not send a second project RPC for an action already synchronized by the integration.
For runtime character selection, derive from SpawnManagerBase and override GetCharacterPrefab(Player). The copyable implementation and deterministic-selection warning are on Scene Setup.
The add-on implements the Ultimate Character Controller networking contracts through components such as PunNetworkInfo, PunCharacter, and PunObjectPool. Query their ownership and role results before project code applies authoritative damage, inventory, spawn, or respawn changes. PUN is client-authoritative, so a competitive game needs validation beyond merely synchronizing the controller action.
When a runtime object is missing or duplicated, identify the owner of the decision first, then check the processed prefab, Photon View, stable identifiers, and PunObjectPool registration. Troubleshooting maps the common symptoms to those setup boundaries.
Folder structure
The add-on is imported into Opsive/UltimateCharacterController/Add-Ons/Multiplayer/PhotonPUN. Runtime and editor synchronization code is under Scripts. The included demo also depends on the main Ultimate Character Controller demo assets.