Discover how Edgegap works

Discover how Edgegap works

/

/

Megacity Metro (Mobile)

Unity Engine

Megacity Metro (Mobile)

Deploy to Edgegap

Published

Published

Published

Megacity Metro (Mobile): Run Unity's Netcode for Entities shooter on Edgegap dedicated servers, with Matchmaking

Megacity Metro (Mobile): Run Unity's Netcode for Entities shooter on Edgegap dedicated servers, with Matchmaking

Megacity Metro is Unity's multiplayer shooter sample: up to 150 players fly through a city in one match, built with Netcode for Entities (DOTS/ECS). Upstream, it runs on Unity Gaming Services. Edgegap's fork runs its dedicated server on Edgegap and finds matches with the Edgegap matchmaker.

The game's netcode doesn't change: same server-authoritative Netcode for Entities, same prediction and lag compensation. The fork adds a few Edgegap files and two small hooks. With the Edgegap settings left empty, the game behaves exactly like upstream.

Players press Find Match, the matchmaker starts a dedicated server, and players who search later join that running server through backfill, up to 150 per server. The server stops its own deployment when nobody is playing.

Mobile status, 21 October 2026: phones join through Find Match, because mobile release builds hide the direct Connect option. That matchmaker path works and was tested with Windows clients. Android and iOS builds have not been tested on Edgegap yet.

Edgegap's network spans 615+ Edge Cloud locations (learn more). Each server is deployed to the best available location for its players and billed only while it runs.

Platforms: Linux dedicated server. Tested clients: Windows. Android, iOS and macOS are supported by the upstream game but not tested on Edgegap yet. Original game by Unity Technologies, under the Unity Companion License.

How it works

  1. A player presses Find Match. The client sends a solo ticket to the Edgegap matchmaker, with no Unity Gaming Services sign-in.

  2. The matchmaker groups players into profile metro (one team of 2 to 150) and starts an Edgegap deployment for the match.

  3. The server boots, listens on UDP port 7979 and skips UGS sessions. Each client gets the server's IP and external port, connects, and sends its ticket ID so the server can count seats.

  4. While seats are free, the server keeps backfill tickets open. A player who searches later is sent to this running server instead of a new one.

  5. When nobody is left, the server closes its backfills and stops its own deployment, which ends billing.

What the fork changed:

Path

What it does

Assets/Scripts/Gameplay/Mix/Multiplayer/Edgegap/EdgegapEnvironment.cs

Reads what Edgegap injects into a deployment, and the client's direct-connect target.

Assets/Scripts/Gameplay/Mix/Multiplayer/Edgegap/EdgegapServerLifecycleSystem.cs

Server: stops the deployment when nobody joins or everyone has left.

Assets/Scripts/Gameplay/Mix/Multiplayer/Edgegap/EdgegapMatchmakerClient.cs

Client: queues a solo ticket and returns the server's IP and port.

Assets/Scripts/Gameplay/Mix/Multiplayer/Edgegap/EdgegapBackfillSystem.cs, EdgegapTicketRpc.cs

Server: keeps backfills open while seats are free, and matches connections to tickets.

Assets/Scripts/Gameplay/Mix/Multiplayer/Edgegap/EdgegapMatchmakerSettings.cs, Assets/Resources/EdgegapMatchmakerSettings.asset

Matchmaker URL, auth token, profile and backfill limits, shared by client and server.

Assets/Scripts/Gameplay/Mix/Multiplayer/SDK/Server/ServerManager.cs

Hook: on Edgegap, skips UGS sessions.

Assets/Scripts/Gameplay/Mix/UI/MonoBehaviours/Matchmaker/MatchMakingConnector.cs

Hook: Find Match uses the Edgegap matchmaker, or connects straight to a server.

Assets/Edgegap/Editor/EdgegapServerBuild.cs

Tools → Edgegap → Build Linux Dedicated Server, also from the command line.

Dockerfile, .dockerignore, matchmaker-config.json

Server image and matchmaker configuration.

No credit card required. Free tier includes the resources to deploy a real game server.

No credit card required. Free tier includes the resources to deploy a real game server.

Megacity Metro skyline at dusk, with a flying vehicle near a glowing tower, and the Unity logo.

Unity's Megacity Metro, a Netcode for Entities shooter, with its server on Edgegap.

Step-by-Step Guide

Run the Sample

1. Before you start

  • A free Edgegap account. No credit card is needed to test.

  • Unity 6000.1.0f1 with Linux Build Support (IL2CPP), Linux Build Support (Mono) and Linux Dedicated Server Build Support, plus the module for your client platform (Windows Build Support (IL2CPP) for the tested client).

  • Docker Desktop, running.

  • Git LFS, installed before you clone: the project holds about 415 MB of LFS content. Plan time: Unity says the first clone, the first project open and the first build can each take 20 to 50 minutes.

  • Clone the fork. Download as ZIP doesn't work for this project.

Git: Unity needs a Git client (2.14.0 or newer) on your PATH to install packages from a Git URL, such as the Edgegap plugin. macOS usually has one already (Xcode Command Line Tools); on Windows, install Git.

2. Build the server and push the image

Close the project in the Unity Editor, then build the Linux dedicated server from the project root:

Unity -batchmode -quit -buildTarget Linux64 -standaloneBuildSubtarget Server -projectPath . -executeMethod EdgegapServerBuild.Build -logFile build.log

Keep -buildTarget Linux64 -standaloneBuildSubtarget Server: without them, the Entities content build fails with "Unable to build with the current configuration". You can also use Tools → Edgegap → Build Linux Dedicated Server in the Editor.

The build lands in Builds/EdgegapServer/ (about 3.4 GB, mostly debug files). The fork's .dockerignore leaves those out, so the image is about 537 MB.

Log in with the username and token from the Container Registry page, then build and push with a new tag each time:

docker login registry.edgegap.com

docker build --platform linux/amd64 -t registry.edgegap.com/<project>/megacity-metro:<tag> .

docker push registry.edgegap.com/<project>/megacity-metro:<tag>

3. Create the app version

In the dashboard, create the application megacity-metro and a version for your image:

  • Image <project>/megacity-metro, your tag, with your registry username and token. Without them, deployments fail to pull the image.

  • 1 vCPU and 2 GB, the tested size. An idle server used about 18% CPU and 323 MB.

  • One port: name gameport, 7979, UDP.

Optional environment variables on the version: EDGEGAP_FIRST_PLAYER_TIMEOUT_S and EDGEGAP_EMPTY_TIMEOUT_S (self-stop timers), EDGEGAP_MAX_PLAYERS and EDGEGAP_MAX_OPEN_BACKFILLS (backfill limits), and UNITY_COMMANDLINE_ARGS for extra server arguments.

4. Test a server with a desktop client

Before adding the matchmaker, prove the server works. Deploy the version from the dashboard, near you. The server log shows Running on Edgegap ... skipping UGS sessions.

Start a desktop client with the deployment's host and external port (on the deployment page; it isn't 7979):

<client executable> -edgegapConnect <host>:<external port>

Or set EDGEGAP_CONNECT=<host>:<external port> before launching it. The host can be the IP or the FQDN. With a direct-connect target, the client skips UGS sign-in and needs no UGS project. The server logs [Edgegap] Connected players: 1 when you join.

Direct connect is for desktop testing only: mobile release builds hide the Connect option, so phones use Find Match (step 6).

For a quick Windows test client, build with Mono instead of IL2CPP (the IL2CPP Master build took about 40 minutes and 12 GB of RAM):

Unity -batchmode -quit -projectPath . -executeMethod EdgegapServerBuild.BuildClient -edgegapClientTarget win64 -edgegapClientMono -buildTarget Win64 -standaloneBuildSubtarget Player -logFile client.log

It lands in Builds/Client/win64-mono/. Keep -standaloneBuildSubtarget Player after a server build, or the build fails with "script class layout is incompatible".

Stop the deployment when you're done. The free tier runs one deployment at a time.

5. Add it to your own Netcode for Entities game

The fork is a working reference: your coding agent can copy its tested files instead of writing them from scratch. Five changes make a Netcode for Entities game run on Edgegap:

  1. The server skips UGS on Edgegap. When the ARBITRIUM_REQUEST_ID variable is set, the server starts without UGS sessions (ServerManager.cs, EdgegapEnvironment.cs).

  2. The server stops itself. A server-world system calls ARBITRIUM_DELETE_URL when nobody joins or everyone has left (EdgegapServerLifecycleSystem.cs).

  3. Find Match uses the Edgegap matchmaker. The client queues a ticket with the Edgegap Unity SDK and passes the returned IP and port to the game's existing connect flow (EdgegapMatchmakerClient.cs, MatchMakingConnector.cs).

  4. Running servers keep filling. A server-world system keeps backfills open while seats are free, and clients send their ticket ID over an RPC after connecting (EdgegapBackfillSystem.cs, EdgegapTicketRpc.cs).

  5. A Linux server build and an image. Assets/Edgegap/Editor/EdgegapServerBuild.cs builds the server; the fork's Dockerfile and .dockerignore keep debug files out of the image.

Then create the app version and matchmaker as in steps 3 and 6.

With your agent:

"Load the edgegap skill, then edgegap-unity. My game uses Netcode for Entities. Using github.com/edgegap/netcode-game-sample-unity-dots-ecs-mobile-megacity-metro as the reference, add a server-world system that stops the Edgegap deployment when the server is empty, make Find Match queue with the Edgegap matchmaker and connect to the returned address, add server backfill with ticket IDs sent over an RPC, and build the Linux dedicated server into the fork's Dockerfile."

Edgegap's skills have no Netcode for Entities templates yet: edgegap-unity covers the Unity workflow, and the fork's ECS systems are the reference for the netcode parts.

For each step in detail, by hand, see the Unity Engine integration guide.

6. Find Match with the Edgegap matchmaker

This is the path phones use. It was tested with Windows clients on 21 October 2026, not yet on Android or iOS.

  1. Set application.version in matchmaker-config.json to your app version. Profile metro is one team of 2 to 150 players. Two players searching together get one server about 10 seconds after they queue, and a lone player gets one after 30 seconds. That suits testing; raise the minimum for real matches.

  2. In the dashboard, open Matchmaker, select Create Matchmaker, upload matchmaker-config.json, then select Create and Start.

  3. When it's ONLINE, copy the API URL and Auth Token into Assets/Resources/EdgegapMatchmakerSettings.asset. The Auth Token is safe to ship in clients: it gives no access to your Edgegap account.

  4. Rebuild the server and the clients. Both read this asset: clients to find matches, the server to create backfills. Then push a new tag and create a new app version.

Press Find Match in a client. The status goes "Searching...", "Match found, starting server...", then the client connects. Batch-mode clients (-batchmode -nographics) matchmake on their own.

Backfill (join in progress). Every ticket carries a backfill_group_size attribute: clients send ["new", "1"] (a new match, or one seat on a running server), and the server sends ["1"]. The server gives each matched player 60 seconds to connect, keeps up to 3 backfills open while seats are free, and closes them all before it stops.

Self-stop. The server stops its deployment 300 seconds after start if no player ever connected, or 60 seconds after the last player left. Players who are matched but still connecting keep it running.

On the free tier, the matchmaker stops 3 hours after each start; restart it from the dashboard (its URL and token stay the same). When you ship a new server build, update application.version in the matchmaker (Stop, Edit, Start).

Known limits

  • Phones are not tested yet. Android and iOS builds should reach Edgegap through Find Match, the path tested with Windows clients, but no phone has joined an Edgegap server yet. A windowed desktop playtest hasn't been done either; tested clients ran headless.

  • No ticket validation. The server logs a connection whose ticket it wasn't given, but still lets it in.

  • Backfills outlive an outside stop. If a deployment is stopped from the dashboard, the API or its max duration, the server exits without closing its backfills. For up to 5 minutes, they can send a player to the stopped server; that player's connection times out, and the next Find Match works.

  • Vivox and UGS sign-in are untouched. The Edgegap paths don't use them, and the in-game Connect mode's session browser still lists UGS sessions.

What was tested

Tested on Edgegap with Unity 6000.1.0f1 and a 1 vCPU / 2 GB app version on 7979/UDP. Clients were Windows builds, run headless (-batchmode -nographics).

  • 20 October 2026, direct connect: a Windows IL2CPP client connected with -edgegapConnect and the server logged the player joining. The deployment stopped itself with no player (1502 s, timeout set to 1500 s) and about 60 s after the client quit.

  • 21 October 2026, matchmaker (free tier, profile metro): two Windows clients (Mono builds) queued together, got MATCH_FOUND then HOST_ASSIGNED for the same deployment, and both connected. A third client went from SEARCHING straight to HOST_ASSIGNED on that running deployment through a backfill, and joined. After all three quit, the deployment stopped itself.

  • Locally (server in Docker, mocked Edgegap variables, real matchmaker): when no matched player connected within 60 s, the seats were released and the backfills closed.

  • Not tested: Android, iOS and macOS clients.

Frequently Asked Questions

Questions about running Unity's Megacity Metro and Netcode for Entities on Edgegap.

Can Netcode for Entities run on Edgegap dedicated servers?

Yes. Build the game for the Linux Dedicated Server target and run it in a container on Edgegap. Megacity Metro's server runs on Edgegap with its netcode unchanged: the fork only adds a few Edgegap files and two small hooks.

Does the Megacity Metro sample work on mobile with Edgegap?

Not tested yet. Phones join through Find Match, which now uses the Edgegap matchmaker and works with Windows clients. Android and iOS builds haven't joined an Edgegap server yet.

Can players join a Megacity Metro match that already started?

Yes, through backfill. While a server has free seats, it keeps backfill tickets open with the Edgegap matchmaker, so players who search later join it, up to 150 per server.

Do I still need Unity Gaming Services?

Not for hosting or matchmaking. On Edgegap, the server skips UGS sessions, and Find Match and direct connect skip UGS sign-in. Vivox voice chat still uses UGS.

Clients

Learn more from clients who integrated Edgegap

31 case studies are available from studios that moved to Edgegap from another platform.

Key reasons why they chose Edgegap

Discover the impact of Edgegap's automated game server orchestration for a flawless multiplayer experience.

Cost

Pricing

Pricing

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Optimize costs and performance with hybrid orchestration

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Edge Cloud

On-Demand

$0.00115

/ vCPU

/ MINUTE

Billed by the Minute, Only on Usage

Pay only when players play. 0 active servers = $0

Deploy game servers worldwide, per instance, to all 615+ edge cloud locations. Zero commitment.

Simply add a credit card.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Private Fleet (Bare Metal)

Reserved Capacity

$0.0261

/ vCPU

/ HOUR

Billed Monthly, Always On

$280 per host/month (12 mo rate), or $350 monthly

Optimize the cost effectiveness of your game server with egress-free hosting of Private Fleets.

Persistent, available 24/7, exclusive to your studio.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Your bill varies per rate and usage; which can vary per game type, player count, & more.

Model your usage with our estimate calculator ->

Model your usage with our estimate calculator ->

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

Edgegap's features & price: detailed comparison between Edge Cloud & Private Fleets

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.

COMPARE

Free Trial

Edge Cloud

Private Fleets

FEATURES

Analytics & Monitoring

Billing Alarms

Click to Expand

28 more rows

Unlocks

Capabilities are unlocked when a credit card is added to the account.