Multiplayer Advanced
In multiplayer experiences, each player's avatar must be visible to all other players with synchronized position, animation, and lip sync. This lesson covers avatar instantiation, state synchronization, and voice chat integration using popular Unity networking frameworks.
Networking Framework Options
| Framework | Best For | Key Feature |
|---|---|---|
| Photon PUN 2 | Room-based games, social apps | Easy setup, cloud-hosted |
| Unity Netcode for GameObjects | First-party Unity projects | Deep Unity integration |
| Mirror | Open-source, self-hosted | Community-driven, flexible |
Avatar Synchronization
The key challenge is that avatars are loaded dynamically from Ready Player Me URLs, not from prefabs in the project. You need to:
- Share the avatar URL
When a player joins, send their Ready Player Me avatar URL to all other clients via a network RPC or custom property.
- Load remotely
Each client loads the avatar from the URL independently. Use the SDK cache to avoid redundant downloads.
- Sync transforms
Use NetworkTransform or Photon Transform View to synchronize position and rotation at a fixed tick rate.
- Sync animations
Synchronize Animator parameters (Speed, Direction, etc.) across the network. Use NetworkAnimator or custom RPCs for state changes.
Voice Chat Integration
For social and meeting applications, integrate Photon Voice or Vivox for spatial voice chat. Route the voice audio through the lip sync system so remote players see lip movement matching the speaker's voice.
Lilly Tech Systems