Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Some simple scripts covering different networking needs that you may find useful:
Keeps a score that is synced across the Network.
Tips and trips for setting up Continuous Integration (CI) for your projects
Continuous Integration means that any changes to the project are merged frequently into the main branch, and automation (especially of testing) is used to ensure quality. The main benefits of Continuous Integration (henceforth CI) are that it makes software development easier, faster, and less risky for developers. Building your Game Client with CI and automated testing might require coherence setup.
For automated delivery of your project changes and testing it in CI, you can take the following steps to make sure coherence is set up appropriately in your project before building a standalone Client.
Make sure you gather your schema or schemas before building. For example, you can create a build method and call it from Unity via command line as a custom method.
After that, you will need to your code according to the schema. You can do it using two methods. If you use default schema locations you can also create a custom method and call it from Unity in CLI.
...or, if you use custom schemas, you can run the CLI command using your schemas and Gathered.json
path.
Besides that, you can use scripts /project_path/Library/coherence/run-safe-protocol-code-generator.sh
and/or /project_path/Library/coherence/run-protocol-code-generator.sh
to generate coherence code.
To start the Replication Server in CI you can also use scripts generated in ./Library/coherence
folder /project_path/Library/coherence/run-replication-server-rooms.sh
and /project_path/Library/coherence/run-replication-server-rooms.sh
.
If you want to automate the uploading of schemas, keep in mind that you need to set the COHERENCE_PORTAL_TOKEN
environment variable in your continuous integration setup so the upload is accepted by the coherence Cloud. You can get the token from coherence Portal > Dashboard > Projects > Project Settings > Project Token.
There are two methods you will need to call, in order, to build and upload a Simulator build successfully:
Coherence.Build.SimulatorBuildPipeline.PrepareHeadlessBuild This method will add the COHERENCE_SIMULATOR scripting symbol, will set the build sub target to Server (for Unity 2021) and it will change the platform to Linux. It is necessary to perform these steps in an isolated Unity execution, because in batch mode, there is no editor loop that will make sure your assemblies are reloaded with the changes.
Coherence.Build.SimulatorBuildPipeline.BuildHeadlessLinuxClientAsync ****This method will build the Unity Client and upload it to your selected organization and project.
In order to be able to interact with your coherence Cloud project from the command line, you will need to export your project token as an environment variable.
coherence SDK supports networking in WebGL without any additional setup. Both Rooms and Worlds are supported.
WebGL builds use webrtc to connect to the Replication Server and so the ports used to connect are different from the usual UDP ports. This is managed automatically in the sample connect dialogs, but if you are building your own, you need to make sure you're connecting to the the correct port which is specified by the --signalling-port
when starting the Replication Server locally (defaults to 42002 for Rooms and 32002 for Worlds).
This is resolved automatically when using the to create and join Rooms and Worlds.
For anyone building WebGL in Linux: you need to install these packages:
sudo apt install clang libtinfo5 python python-setuptools
For running a WebGL build locally, please refer to the .
The Unreal SDK is under development. We're looking for partners or studios that want to take a sneak peek.
Contact for more information or collaboration options.
You can also join our to get in touch with the team directly.
You can use the Simulator Build Pipeline public API to build and upload your Simulator builds to the coherence Cloud from the command line. If you wish to learn more about Simulators, check out the .
You can create your custom build steps by implementing Unity interfaces and . In order to verify that the build being created is a Simulator, you can check for the SimulatorBuildPipeline.IsBuildingSimulator boolean.
A list of common terms and concepts used in coherence.
A coherence term for the process of generating network code for your GameObjects. See code generation.
Bandwidth is the data that your game servers are using up to sync your Room or World and all the players within it.
Also known as CoherenceBridge. The Bridge is a system that makes sure every GameObject is linked to its networked representation. It essentially interfaces between the GameObject world and the coherence SDK code running "under the hood". When you place a GameObject in your scene, the Bridge detects it and makes sure all the synchronization can be done via the CoherenceSync component.
A CCU hour represents the time that a Room or World is online. The CCU hour consumption per Room or World is determined by the maximum player capacity they are reserved for, regardless of how many players are active within them.
A Client connection represents a participant or Simulator in a game you're playing online.
A CoherenceSync representing a Client connected to the Replication Server. Required to send Client Messages.
The process of generating code specific to the game engine that takes care of network synchronization and other network-specific code. This is done using a CLI tool called Protocol Code Generator that takes the Schema file and generates code for various engines (e.g. C# for Unity).
The backend of the coherence Developer Portal.
CoherenceInput is a Component that enables a Simulator to take control of the simulation of another Client's objects based on the Client's inputs. Each object can only accept inputs from one specific Client, called the object’s Input Authority. You should use CoherenceInput when a) you want a centralized simulation of all inputs b) Clients have low processing power c) determinism is important for your project.
CoherenceSync is a component that should be attached to every networked GameObject. It may be your player, an NPC or an inanimate object such as a ball, a projectile or a banana. Anything that needs to be synchronized over the network and turned into an Entity.
The coherence software development kit plugin for Unity, allowing your Unity project to make use of coherence for multiplayer.
Allows for sending an instruction to an Entity that may be running on a different machine.'
Dashboard is the front-end of the coherence Developer Portal that is used for managing your coherence projects.
These are useful features for multiplayer games that coherence offers like the Key-value store and Authentication Service (Player Accounts). More info is available in the Game Services and Lobbies articles.
See CoherenceInput. Replaced InputOwner.
The KV Database, also know as a key-value store, provides a simple persistence layer for the players. The KV Database matches a short key (identifier) to a specific value (data payload) held in a simple, unstructured database. For example, KV store can be used to store the player's score, email address, or any other data. There are no limits to the total number of key/value pairs as long as the total size stays under 256KB.
A common game optimization technique for saving resources spent on rendering or syncing GameObjects not in the immediate vicinity of the player/camera. Commonly, several LODs are applied in a gradual manner so the transitions seem smooth. In coherence, Archetypes let you group Components together and create distinct "levels of detail". Each such level must have a distance threshold, and a list of Components that should be present at that distance.
Used for filtering Entities that receive updates via CoherenceSync by distance and relevance, as an optimization measure (latency, compute). LiveQuery area is shaped like a box, and the distance is measured from middle to edges. Also, see TagQuery.
LODs data can be added to any Prefab with the CoherenceSync component. It contains a list of the various levels of detail (LODs) that this particular Prefab can have. See Level of Detail.
Multi-Room Simulators are Room Simulators which are able to simulate multiple Game Rooms at the same time.
The business entity that uses coherence for its project(s).
It is a separate application whose only job is to write the persitent objects to the disk. After say a crash the Persistance Client would read the file from the disk and send it to the Replication Server. The save frequency is set to 30 seconds by default.
Either a game project or other project, connected to an Organization.
A lean and performant server that keeps the state of the World and replicates it efficiently between various Simulators and Game Clients. The Replication Server usually runs in the coherence Cloud, but developers can start it locally from the command line or the Unity Editor.
Short-lived multiplayer environments for dozens of players. Perfect for quick session-based matches. See Worlds.
The Schema is a file that defines which data types in your project are synced over the network. Schema specifies all the relevant data to be communicated to the Replication Server like name, hitpoints, level, speed, etc. It has two primary uses:
As a basis for code generation, creating various structs and methods that can be used in your project to communicate with the Replication Server.
As a description for the Replication Server, telling it how the data in your project looks like – to receive, store, and send this data to its Clients.
A way to bundle and run the Replication Server with the game, so that players can host games without using the coherence Cloud. Read more about it in the Client-hosting article.
A Simulator is a headless client running game logic in the server that is syncing all the changes in the Room or World to all the players. It ensures a stable connection and is a way to make your multiplayer game logic tamper-proof. Find out more about Simulators in our developer documentation.
A string of text that uniquely identifies an uploaded Simulator, making it easy to differentiate between various World or Room Simulators during deployment. The Simulator slug should be descriptive for ease of use purposes, although coherence supports any string value.
State authority, when given to a Simulator or a Client, means they can change the state of Entities in the game. In server-authoritative games state authority is given to a Simulator for anti-tampering reasons, but for casual projects it can lie with Clients that create the Entities. However, coherence allows for flexibility as well - for example, state authority can be configured so it can be transferred to other Clients or Simulators, and reassigned continuously in the course of the game. Additionally, see Input Authority.
What the Replication Server is doing by determining the state of the game and then syncing it to all the connected Clients.
Storage here relates to the cost of keeping data on coherence Cloud. It is measured in terabytes (TB) per hour.
In addition to the LiveQuery, coherence also supports filtering objects by tag. This is useful when you have some special objects that should always be visible regardless of World position. Also, see LiveQuery.
Long-lived and permanent multiplayer environments for thousands of players. Best suited for MMO-type games. See Rooms.
We now offer full peer-to-peer support. This makes it easy for the players of your coherence-enabled game to host Replication Servers themselves, without using our cloud services.
For the particulars, see our client-hosting article.