> 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/unreal-engine/top-down-sample.md).

# Top-Down Sample

Deploy an Unreal Engine top-down sample as a dedicated server on Edgegap, a practical starting point for solo developers and small teams.

Launching an Unreal Engine game with dedicated game servers can be daunting project, from individual developers to experienced medium-sized teams.

Fortunately, the Edgegap platform makes it easy, with a simple integration process that takes minutes. Your game will then be online, ready to connect players worldwide to play. Helping you allocate precious development resources to what you love - making a great game.

{% hint style="success" %}
See our [Unreal Engine sample project](https://github.com/edgegap/game-sample-unreal-engine-topdown) using the Top-Down sample for inspiration.
{% endhint %}

{% hint style="info" %}
See [Unreal Engine](https://docs.edgegap.com/unreal-engine.md) to **learn how to build and customize servers**.
{% endhint %}

This sample shows:

* Unreal Engine Top-Down project packaged as a Linux dedicated server, with a `Dockerfile` for Edgegap,
* connecting clients by IP with console command `open <YOUR_DEPLOYMENT_IP:PORT>`,
* optional [Matchmaking](https://docs.edgegap.com/learn/matchmaking.md) integration with a **Find Match** button, [Ping Beacons](https://docs.edgegap.com/learn/orchestration/ping-beacons.md) latencies and server self-stop,
* optional in-game voice chat with Epic Online Services, see [EOS Voice Chat](https://docs.edgegap.com/docs/tools-and-integrations/eos-voice-chat.md).

Both optional features are **disabled by default**. Until you enable them, the game works as described in [Unreal Engine](https://docs.edgegap.com/unreal-engine.md) guide.

{% hint style="info" %}
The included `Dockerfile` starts your server with `-stdout -FullStdOutLogOutput`. **Without these flags, stdout is buffered and your deployment logs stay empty.**
{% endhint %}

## 🎯 Matchmaking (Optional)

With matchmaking enabled:

* the menu map shows a **Find Match** button - it measures the player's ping to [ping beacons](https://docs.edgegap.com/learn/orchestration/ping-beacons.md), creates a matchmaking ticket with those latencies, waits for the matchmaker to start a server near the players, then connects to it,
* `FindMatch` and `CancelMatch` also work as console commands, and launching a client with `-FindMatch` queues automatically, useful when testing with several clients,
* servers started by the matchmaker stop their own deployment 15 seconds after the last player leaves, or after 5 minutes if nobody joins, so idle servers don't keep billing. Servers you deploy by hand, or run locally, are never stopped.

### 1. Package and Upload the Server

☑️ Package the Linux dedicated server into `Packaged/` (engine built from source, with Linux cross-compile toolchain):

{% code collapsedlinecount="10" %}

```shell
<UE_ROOT>/Engine/Build/BatchFiles/RunUAT.bat BuildCookRun -project=<PATH>/MultiplayerGame/MultiplayerGame.uproject -noP4 -server -noclient -serverplatform=Linux -serverconfig=Development -build -cook -stage -pak -archive -archivedirectory=<PATH>/Packaged
```

{% endcode %}

{% hint style="success" %}
Prefer not to build Unreal Engine from source? See [Build from Plugin](https://docs.edgegap.com/unreal-engine/more-build-methods.md#build-from-plugin).
{% endhint %}

☑️ Build your image from the repository root with the included `Dockerfile` and push it to your registry:

{% code collapsedlinecount="10" %}

```shell
docker build --platform linux/amd64 -t <REGISTRY>/<IMAGE>:<TAG> .
docker push <REGISTRY>/<IMAGE>:<TAG>
```

{% endcode %}

{% hint style="danger" %}
:x: **DO NOT - overwrite existing tags or use `latest`  tag** - this will deploy an outdated cache.\
:white\_check\_mark: **DO - always increase your version tag** and deploy the new build.
{% endhint %}

☑️ [Create an app version](https://app.edgegap.com/application-management/applications/list) with [port](https://docs.edgegap.com/learn/orchestration/application-and-versions.md#port-mapping) `7777`, protocol `UDP`, named `gameport`.

✅ You may now proceed to the next step.

### 2. Create a Matchmaker

☑️ Set `application.name` and `application.version` to your app and version in `matchmaker-config.json`.

☑️ [Create a matchmaker](https://app.edgegap.com/matchmaker-management-v2/matchmakers/list) from this configuration. Its `casual` profile:

* matches 2 to 4 players with ping to a common beacon under 150 ms and within 100 ms of each other,
* after 10 seconds of waiting, also accepts a single player and pings up to 250 ms (see [Rule Expansion](https://docs.edgegap.com/learn/matchmaking/matchmaker-in-depth.md#rule-expansion)),
* cancels a ticket after 20 seconds without a match - press **Find Match** again.

{% hint style="warning" %}
Your client sends beacon latencies because the profile has a `latencies` rule. If you remove that rule, **set `bSendBeaconLatencies=False` in `DefaultGame.ini`, otherwise the matchmaker rejects tickets.**
{% endhint %}

✅ You may now proceed to the next step.

### 3. Point the Game to Your Matchmaker

☑️ Enable matchmaking in `MultiplayerGame/Config/UserGame.ini`, which is git-ignored and overrides `DefaultGame.ini`, keeping your values out of version control. Replace `YOUR_MATCHMAKER_URL` and `YOUR_MATCHMAKER_AUTH_TOKEN` with the URL and Auth Token from your matchmaker's dashboard page:

{% code collapsedlinecount="10" %}

```ini
[/Script/MultiplayerGame.EdgegapMatchmakerSubsystem]
bEnabled=True
MatchmakerUrl="YOUR_MATCHMAKER_URL"
AuthToken="YOUR_MATCHMAKER_AUTH_TOKEN"
```

{% endcode %}

{% hint style="warning" %}
**Keep your URL in quotes.** Unquoted, Unreal's ini parser cuts it at `//`.
{% endhint %}

{% hint style="danger" %}
**Do not integrate Edgegap API endpoints in game client, as your API token provides unlimited access to your account. See** [Integration](https://docs.edgegap.com/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 %}

✅ You may now proceed to the next step.

### 4. Find a Match

☑️ Launch two clients and press **Find Match** in both within 10 seconds. They join the same server.

🙌 Congratulations on your first matchmade Deployment on Edgegap!

## 🎙️ Voice Chat (Optional)

The sample can also add in-game voice chat with EOS Voice from Epic Online Services. Your dedicated server acts as the trusted server - it checks each player's EOS identity, picks their voice room (one per matchmaker team, or one per match) and hands each player their own room token.

See [EOS Voice Chat](https://docs.edgegap.com/docs/tools-and-integrations/eos-voice-chat.md) to learn how it works and how to set it up.
