Relay doesn't synchronize data or GameObjects. It only carries network traffic between players. To keep game state in sync over Relay, use a netcode library such as Netcode for GameObjects or Netcode for Entities, or write your own synchronization code, and use Relay as the transport underneath.
What does Relay do?
Relay sits between game clients and routes their network traffic to the right destination. Its job is data transport only. It doesn't manage game state or provide built-in synchronization for player positions, GameObject states or other dynamic parts of your game.
How do I synchronize data and GameObjects with Relay?
Choose one of these options:
-
Netcode for GameObjects: a high-level library for synchronizing GameObjects. Use
NetworkVariableto replicate state and RPCs to send events, so game state stays consistent for all players. - Netcode for Entities: the netcode library for projects built with Unity's Data-Oriented Technology Stack (DOTS). It synchronizes entities rather than GameObjects and suits large-scale, high-performance games.
- Custom implementation: if you need specific networking features or full control over what is sent and when, write your own synchronization code and use Relay only to transmit the data.
If you use Sessions in the Multiplayer Services SDK, call WithRelayNetwork() on your session options, and the SDK sets Relay up as the transport for you.
For details, see the Netcode for GameObjects documentation and the Netcode for Entities documentation.