com.unity.services.samples.multiplayer-chess-cloud-code

OTHER License

Stars
23
Committers
3

Multiplayer Chess Sample

A sample project that demonstrates how to implement a server authoritative asynchronous multiplayer game using Unity Gaming Services, without needing a dedicated game server.

Setup

To run the chess sample, import the Chess folder as a Unity project, open and run the ChessDemo.unity scene.

For this sample to work, you first need to publish your Cloud Code Module and Leaderboard via the Deployment Window.

To access the Deployment window:

  • In 2021 or before, use Window > Deployment.
  • In 2022 and later, use Services > Deployment.

Then click on Deploy All to deploy both ChessCloudCode.ccmr and EloRatings.lb. See Deployment Window for more information.

To run another game client locally to play against, go to File -> Build and Run. Then you can create a game in one client, and join it in the other using the generated code shown in the top right of the game window.

To limit access to specific Cloud Code endpoints from authenticated players (i.e. the game client), have a look at the Access Control documentation.

.NET Requirement

To deploy Cloud Code Modules in the editor you must first install .NET.

Follow the steps below to set your default .NET path in editor:

  1. In the Unity Editor, select Edit > Preferences > Cloud Code.
  2. In the .NET development environment section, modify your .NET path to the one you have it installed.
  3. Select Apply.

Alternative Setup

Alternatively to using the Deployment Window, you can publish your Cloud Code module and Leaderboard via the UGS CLI. Remember to install and configure the CLI first. This requires a project ID, environment name and a service account key, all of which can be created and found in the Unity Dashboard.

Once the CLI is set up, the module and leaderboard can be deployed with the following commands (or by running the deploy.sh script):

ugs deploy ChessCloudCode/ChessCloudCode.sln --services cloud-code-modules
ugs deploy Chess/Assets/Setup/EloRatings.lb --services leaderboards

Credits

This project uses the Free Low Poly Chess Set asset for the board and chess pieces, and the Gera Chess Library for validating the moves made by players.

See Third Party Notices for more information.

Related Projects