The topics of this page are covered in the first minute of this video:
It's quick and easy to set up a networked scene from scratch using the coherence SDK. This example will show you the basic steps to sync up some moving characters.
Add these components to your scene to prepare it for network synchronization.
coherence > Scene Setup > Create MonoBridge
This object takes care of connected GameObject
lifetimes and allows us to develop using traditional MonoBehaviour
scripts.
coherence > Scene Setup > Create LiveQuery
Creates a LiveQuery which queries the area around the local player to get the required information from the Replication Server. You can surround your entire scene in one query or can attach it to an object such as the player or a camera.
coherence > Scene Setup > Add Sample UI
Creates a Canvas
(and Event System
if not already present in the scene) with a sample UI that helps you connect to a local or remote Replication Server. You can create your own connection dialog, this one is just a quick way to get started.
Using the coherence Hub window gives you an overview of everything related to networking in your project. The Overview tab will show you the current status and which actions you need to perform for everything to work.
coherence > coherence Hub
If we have identified any issues in your project, the Overview tab provides a one-click solution to solving it. In the example below, simply click the blue link next to the warning messages and coherence will redirect you to the correct place to learn more about how to fix the issue.
The coherence Sample UI
is a Prefab that you can add to your scene. It handles interaction with coherence services, is made up of a Unity UI Canvas and includes everything needed to handle connection to coherence.
The UI
component on the root of the Prefab allows us to switch between using Rooms or Worlds. Each of these methods has a dedicated dialog for connection.
The Auto Simulator Connection
component is used by Simulator builds to connect to the relevant Replication Server.
The Rooms Connect Dialog has a few components that facilitate the usage of Rooms.
At the top of the dialog we have an input field for the player's name.
Next is a dropdown for region selection. This dropdown is populated when regions are fetched. The default selection is the first available region.
Due to current limitations the local Server is fetched only if it's started before you enter Play Mode. The Local Development Mode checkbox must also be checked in the project settings (coherence > Settings).
This affects the local region for Rooms and the local worlds for Worlds.
Beneath these elements is a Rooms list of available Rooms in the selected region.
After selecting a Room from the list the Join button can be used to join that Room.
The New Room tab will take us to the Room creation screen.
This screen contains controls for setting a Room's name and maximum player capacity. Pressing the Create button will create a Room with the specified parameters and immediately add it to the Room List in the previous tab. Create and Join will create the room, and join immediately
The Worlds Connect Dialog is much simpler. It simply holds a dropdown for region selection, an input field for the players name, and a Connect button.
See chapter to learn more about them.
You can also build your own interface to connect players to the Server using thePlayResolver
API. To learn more about the API, see either , or according to what your project needs.