> For the complete documentation index, see [llms.txt](https://docs.edgegap.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.edgegap.com/docs/sample-projects/unity-netcodes/purrnet-incremental.md).

# Purrnet Incremental

Host a Unity Purrnet game on Edgegap, using the Purrnet Incremental sample to walk through build and deployment.

Explore how to host Unity projects on Edgegap using techniques from [Purrnet Incremental Sample](https://purrnet.dev/docs/full-game-guides/incremental-game-sample).

{% hint style="success" %}
Our [fork of the sample](https://github.com/edgegap/PurrNet-Incremental-Sample) runs the game on Edgegap dedicated servers, see [What the Edgegap Fork Adds](#what-the-edgegap-fork-adds).
{% endhint %}

{% embed url="<https://youtu.be/NWa4JfS0d3A>" %}

## ✔️ Preparation

Before we start, you will need:

* Unity 6 - [download using Unity Hub](https://unity.com/releases/unity-6).
* [Purrnet Incremental Sample](https://purrnet.dev/docs/full-game-guides/incremental-game-sample) (clone/download from github).
  * or clone [our fork](https://github.com/edgegap/PurrNet-Incremental-Sample), ready for Edgegap.
* [Purrnet Unity Package](https://purrnet.dev/docs/getting-started/installation-setup) (included in the sample project).
* [Edgegap's Unity Dedicated Servers Quickstart Plugin](/unity.md).
  * Install from git or Purrnet packages - both include the same plugin.

Open your incremental sample project in Unity to get started.

## ⚡ Deploy and Connect

{% hint style="success" %}
See [Unity](/unity.md) to **learn how to build and customize servers**.
{% endhint %}

### 1. Deploy a Server on Edgegap

☑️ To get started, you'll need to [create a free account with Edgegap](https://app.edgegap.com/auth/register). No credit card required.

☑️ Follow the [Unity Getting Started guide](/unity.md) to build and upload your dedicated server.

☑️ [Deploy a server](https://app.edgegap.com/deployment-management/deployments/create) with your newly created Incremental Sample app version.

☑️ [Open your new deployment's details](https://app.edgegap.com/deployment-management/deployments/list) and find your unique, one-time connection details:

* **Host URL** in format `780aa4260e83.pr.edgegap.net` ,
* **External Port** in format `30854` (5 digits).

✅ You may now proceed to the next step.

### 2. Connect from Editor

☑️ Open your new project in Unity.

☑️ Verify that you have opened the main scene: `Scenes/GameScene.unity`.

☑️ Input Network Manager connection details from previous step.

☑️ Press the ▶️ Play button to start your game client.

☑️ Connect a second virtual Player with [Multiplayer Play Mode](https://docs-multiplayer.unity3d.com/mppm/current/about/) or [ParrelSync](https://github.com/VeriorPies/ParrelSync).

🙌 Congratulations on your first Deployment on Edgegap!

## 🧩 What the Edgegap Fork Adds

Our [fork](https://github.com/edgegap/PurrNet-Incremental-Sample) keeps the upstream game and adds everything Edgegap-specific in `Assets/Edgegap/`. See its `EDGEGAP.md` file for full steps.

* **Runtime bootstrap, no scene edits** - `EdgegapBootstrap` runs before the scene loads and adds Edgegap components at runtime, so `GameScene` is not modified. In builds, it disables PurrNet's auto start. In editor, play mode keeps PurrNet's normal host and clone flow unless `Apply In Editor` is ticked.
* **One settings asset** - `Assets/Edgegap/Resources/EdgegapSettings.asset` holds mode, ports, matchmaker URL and Auth Token. Command-line options such as `-edgegapAddress` and `-edgegapPort` override it in builds.
* **Direct connection (default)** - client builds show a connect panel with address and port. Connect to a local server in Docker, or to a deployment you start from [dashboard](https://app.edgegap.com/deployment-management/deployments/list).
* **Edgegap Matchmaker (optional, disabled by default)** - tick `Use Edgegap Matchmaker` in the settings asset and paste your matchmaker's `API URL` and `Auth Token`. Players then click `Find Match` and connect to the assigned server automatically. See [Matchmaking](/learn/matchmaking.md).
* **Server self-stop** - in server builds, `EdgegapServerLifecycle` starts the PurrNet server on `0.0.0.0:7777`. On Edgegap, it stops its own deployment when nobody joins within 120 seconds, or 30 seconds after the last player leaves.
* **UDP port 7777** - your app version needs one [port](/learn/orchestration/application-and-versions.md#port-mapping) named `gameport`, port `7777`, protocol `UDP`, the same default as the other samples. The fork includes a `Dockerfile` and a Tools / Edgegap / Build Linux Dedicated Server menu.

{% hint style="danger" %}
**Do not integrate Edgegap API endpoints in game client, as your API token provides unlimited access to your account. See** [Integration](/docs/api/integration.md) **for secure client-facing API endpoints and functions.**
{% endhint %}

{% hint style="info" %}
Matchmaking Auth Token is scoped to your matchmaker only, so it's safe to ship in game clients.
{% endhint %}

{% hint style="info" %}
The fork changes one upstream line: `ResourceSpawner.InitSeed` is now `[ObserversRpc(runLocally: true, bufferLast: true)]`. **Without `runLocally`, a dedicated server never receives its own seed, so it never spawns trees.** Host mode is not affected.
{% endhint %}
