1. Scene setup
Last updated
Last updated
One of the first steps in adding coherence to a project is to setup the scene that you want the networking to happen in.
The topics of this page are covered in the first minute of this video:
Preparing a scene for network synchronization requires to add three fundamental objects:
In the top menu: coherence > Scene Setup > Create CoherenceBridge
A GameObject with a CoherenceBridge
script will be created.
This object manages the connection with coherence's relay, the Replication Server, and is the centre of many connection-related events.
No particular setup is required now, but feel free to explore the options in its Inspector.
In the top menu: coherence > Scene Setup > Create LiveQuery
A GameObject with a LiveQuery
script will be created.
A LiveQuery defines what part of the world the Client is interested in when requesting data from the Replication Server. When Constrained, it covers limited volume. The Extent property specifies how far it reaches. Anything that is outside the area defined by the LiveQuery will not be synced.
For a big game world, it makes sense to use a small range and parent the LiveQuery to the player character or the camera, so it can move with it. But for now, let's just create a LiveQuery, position it at the centre of the world, and keep it as Infinite (no spatial constraints).
While LiveQueries are an optimisation tool, having at least one LiveQuery is necessary.
In the top menu: coherence > Explore Samples
From the Explore Samples menu, choose Connect Dialog: Rooms. The Prefab will be instantiated in your scene.
A Connect dialog UI provides an interface for the player to connect to the Replication Server, once the game is running. You can create your own connection dialog, but we provide a few examples as a quick way to get started and for prototyping. Read more in the section dedicated to Sample UIs.
In this section, we:
Added a CoherenceBridge to the scene to facilitate connection to the Replication Server
Used a LiveQuery to ensure we receive network updates
Added an in-game UI to allow players to connect over the network
Next: time to setup some Prefabs!