Lightweight Unity Client
Sample Implementation using Unit
Last updated
Sample Implementation using Unit
Last updated
A Unity-based client showcases frontend integration:
Prerequisites: Unity version requirement 2022.3 or higher.
Installation:
You can either clone or download the zip.
With Unity version 2022.3.58f1, open the project folder chain-tactics-unity-client. Once you open the project, you can open a SampleScene which you can either duplicate or replace the content of. It is located at: Assets/Scenes/SampleScene.unity
The scene contains a _WorldSettings prefab which is what you need to connect to the backend.
WorldSettings prefab can be found in Prefabs/Core/ folder which you can drag and drop in your hierarchy.
WorldSettings configuration:
If you are developing your own mod, you can set connection type to development.
To create a new CT connection context, you can do the following steps:
Right-click on the project folder, select Create > Chain Tactics > New Server Connection Configuration.
You can configure CT connection context.
Here is example Local Development Connection Context:
Url
Private Key:
Client 1 Unity Build: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
Client 2 Unity Build: 59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d
World Address - 0x8d8b6b8414e1e3dcfd4168561b9be6bd3bf6ec4b
Sequencer Url (This is required for the target L2 chain)
Chain ID - 31337 (This is required for the target L2 chain)
Building the Lightweight Unity Client
After cloning and configuring the lightweight client to run locally, you will need to build the Unity game with two different client builds. Each client is configured with different private keys (see above) with the end result of launching the two games side by side on your Mac or Windows computer.
The build settings are pretty straightforward. As we have already configured the Local Development connection profile above, we simply need to select the following:
For Client 1, ensure the Development Connection Profile is configured with Anvil private address 1 specified. Ensure build_and_run_contract.sh and build_and_run_contract.sh are running in separate terminal windows.
Select File menu > Build Settings
Ensure the SampleScene is selected
Select your Windows, Mac, Linux operating system
Ensure “Development Build” is selected
Select Build
Specify the target application file name. Name it “Client 1”.
For Client 2, ensure the Development Connection Profile is configured with Anvil private address 2 specified.
Joining the Match with the Unity Lightweight Client
After building the two clients, run them side by side and select the following:
Select Find Match
Once find match is selected, the client will keep searching until another client accepts the match
When both clients have accepted the match, you will transition to the game screen, where you must place your pieces on the board and commit them.
Once you have placed your pieces - enjoy your game!
Git pull repo: