# Lightweight Unity Client

A Unity-based client showcases frontend integration:

* Prerequisites: Unity version requirement 2022.3 or higher.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfw30gGJdQ0UBkBjAh41DBGlDRi4XbGmNvNHjbcEylQHZymIaYN_BVJcxRTygQbXpKQs7ERz92rmAxQIeOddbDyP4Oy-ysjiklYBusWGXAkWGUb7BujBr12ZU-bwVpxrnK9y4Q4fw?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

Installation:

1. Git pull repo:[ ](https://github.com/cellrunner/ct-headless-unity/tree/master)<https://github.com/sovrun/chain-tactics-unity-client>
2. You can either clone or download the zip.
3. 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

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcvGRPWdkbFiX7cZDMYwLF0iBTWfSspxP1U2wU-YlYqQ_J_iOcCuSLweKMy57GkYuSKep69YF5cYM9sdhcAYHNuff7GVgZHCfRi22nDraU2umZwW48WZ1b97mg4IXPfUsoWgdWu?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

4. The scene contains a \_WorldSettings prefab which is what you need to connect to the backend.
5. WorldSettings prefab can be found in Prefabs/Core/ folder which you can drag and drop in your hierarchy.
6. WorldSettings configuration:

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfrX6vtMss9EuMseMPLYjDrE8jHK_nIc_83o-AmAhxzeLIMh9D9mUq2IlnKyLg6dxAhfpOtAlzvEIANKbQNa72LqUrHCp3usgWtFgF4JnTUlEjpMbT7gsbeD4cJIpf0SuwZEhXL?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

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.<br>

  <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe4kexgMv0khf4nP6H5_Sn-2yWWY9mxn48wZZ_dHguZ6KWRyNq_yh5NNqWLbBc4cd_DtWmkQQW1vKR2IavfIr-vo2LefLzyUB_x2YQ3qPnpfRiZ8TwccOlzOD_a07NGAOfEmfOXKg?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>
* You can configure CT connection context.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfnyfN-YWEZkxHfJN8ozRahqoCu-1zPtV8Zcd1z6JqtsntLh2os0b5C2GakOCUHvwiprV70ACTKjiBg3sdIU71CH8Pc28F6ytjCdB28lITEqKNQNC5qYeDGSLDc9fWQpnfPmui0Tw?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

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)

\ <br>

**Building the Lightweight Unity Client**<br>

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.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfHoLYrt0Amx4HEOEhA1edL1n6S14yn5xcevPdIFbMkYVORMzxAvGwYO0UuxMtC2ePjfLyPVpJJ_ofvkq4xjP4CQPAlJ_67cblCAcgMdjY6eyKTZVLrLgcE-ZKWUTugW4x05AY9lA?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

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.

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXc5PQLgjMcjVvTs6JAJXbSeCo2M7onukBvr8sdVnBIlOQOr2gPgs8KcH8ZpiI4B2MHRDl-ePuXXl1ifI4QMHSquAuecQ1YDFqyt2RcvryurmbEqlA5NmHVEK2PX2DV_aBC28H9jAg?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

**Joining the Match with the Unity Lightweight Client**

After building the two clients, run them side by side and select the following:

* &#x20;Select Find Match<br>

  <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXcFdh-S6U0bXEl1wx2AUHMFG_soFxhw7L3EAcPxNtTYfVxNxQ65F-KQWApxtN296ZNZbZPBXkUhivHoCUUYbfAArn9Zu21EUNgBkjPxYVekYl5umAmwahEjeb5BiogVaG3pc9ZaXQ?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>
* Once find match is selected, the client will keep searching until another client accepts the match<br>

  <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfGa2gx2qALmAcegSs8Rl5Um3lJi7zMp8G3ecBVFyIK6-2WFhT7ZbyrcgPWhqxcRfVU12iS0hr2LDFbn7dCUHDnXGJwE3i44kHTsDxiWO4h6F_z5FJs7wUhIhVqSL-fbw5W97diag?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>
* 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.<br>

  <figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXe_oss0Iye0Hg10yYAlXazDWmJNyxElCh9zA0C574Xfh3MbBQPitkIhUTvZrgeImS8k7zs2JILYHfcxdHM7IhH_CKzY_jNW9w7n-slFgpwEWejV-bAO4bkT16sz1gHgHhaiiUCQDQ?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>

Once you have placed your pieces - enjoy your game!

<figure><img src="https://lh7-rt.googleusercontent.com/docsz/AD_4nXfJet-IFvbzBwyb4k1qcNdcbI2ZkaZUoBtgtXj09Y-d_JuBj-XriM4FtOic3M1dlYxX-dwF_X_1KFYN77iRooPWxFmBD1ocSIBi5vUBvr1eYcBYnouRvydiCJhcKmixOdfrJs0e?key=weo2vl887S6ZT9ibnwfRY5gJ" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sovrun.org/build-with-sovrun/chain-tactics/getting-started-guides/lightweight-unity-client.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
