Discover how Edgegap works

Discover how Edgegap works

Mirror Networking

Tanks (WebGL)

Deploy to Edgegap

Published

Published

Published

Tanks (WebGL): Run Mirror's Tanks on Edgegap dedicated servers, with Matchmaking

Tanks (WebGL): Run Mirror's Tanks on Edgegap dedicated servers, with Matchmaking

Tanks is one of Mirror's example games: players drive tanks around an arena and shoot each other. Edgegap's sample builds it for the browser (WebGL) and runs every match on its own dedicated game server.

Mirror and the Tanks game don't change: the sample keeps Mirror's SimpleWebTransport and the original scene, and adds a few optional scripts. Turn them on and players click Find Match instead of typing a server address.

Edgegap's matchmaker groups the players, then starts a server for them. Edgegap's network spans 615+ Edge Cloud locations (learn more), and each server is deployed to the best available location for its players. The browser connects over secure WebSockets, and the server stops itself when the match is empty.

Platforms: WebGL client in the browser; Linux dedicated server. Unity 6.3 LTS (6000.3.11f1), Mirror 86.13.4. Tanks is part of Mirror, under the MIT licence.

How it works

  1. A player opens the game in the browser and clicks Find Match. The client sends a ticket to Edgegap's matchmaker.

  2. The matchmaker groups 2 to 4 players. Browsers can't ping, so it places the server from the players' public IPs.

  3. Edgegap starts the Tanks server near them. The server listens for WebSockets on port 7778, and Edgegap's TLS Upgrade puts a certificate in front of it.

  4. Each client gets the server's host name and external port, and connects to wss://{host name}:{port}, retrying while the server boots.

  5. When everyone has left for 30 seconds, or nobody joins within 2 minutes, the server stops its own deployment.

What the sample adds:

Path

What it does

Assets/EdgegapMatchmaking/TanksMatchmakingClient.cs

Find Match / Cancel panel. Creates the ticket, waits for a server, connects Mirror over wss://.

Assets/EdgegapMatchmaking/TanksMatchmakingServer.cs

Dedicated server only. Reads the variables Edgegap injects and stops the deployment when the match is empty.

Assets/EdgegapMatchmaking/TanksMatchmakingDTOs.cs

Ticket attributes. Add fields here for custom matchmaker rules.

Assets/EdgegapMatchmaking/Edgegap.Tanks.Matchmaking.asmdef

Turns the scripts on only when Edgegap Unity SDK 3.5.5 or newer is installed. Without it they compile to empty stubs.

Assets/EdgegapMatchmaking/link.xml

Keeps the SDK's data classes in IL2CPP builds (WebGL and Linux server).

matchmaker-config.json

Example matchmaker configuration, profile tanks-webgl.

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.

Top-down view of a tank with its health bar on rocky ground, in Mirror's Tanks sample running in a browser.

Mirror's Tanks sample in the browser, with its dedicated 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 6.3 LTS (the sample uses 6000.3.11f1), with Linux Build Support (Mono), Linux Build Support (IL2CPP), Linux Dedicated Server Build Support and Web Build Support added in Unity Hub.

  • Docker Desktop, running while you build the server.

  • Clone the sample and open it in Unity. The Edgegap plugin installs with the 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. Turn on matchmaking

Matchmaking is off by default, so the sample opens and builds without the Edgegap SDK. To turn it on:

First, in Window → Package Manager, select +, then Add package from git URL, and paste:

https://github.com/edgegap/edgegap-unity-sdk.git#3.5.5

Then open the MirrorTanks scene, select the EdgegapMatchmaking object and tick the checkbox next to its name.

Do this before you build the server, so the server includes TanksMatchmakingServer and stops itself when the match is over.

3. Put the game server on Edgegap

Open Tools → Edgegap Server Hosting, connect your Edgegap account, then select Build Server, Containerize with Docker and Upload Image and Create App Version.

In the browser, set the app version's port:

  • Port 7778, protocol WS, name gameport.

  • Verifications on and TLS Upgrade on. TLS Upgrade gives the server a secure WebSocket address, so browsers on https:// pages can reach it. You don't need a certificate of your own.

Step 4 of the Unity WebGL guide covers the plugin screens, and the agent option, in detail.

4. Create the matchmaker and play

Edit matchmaker-config.json at the root of the repository:

  • application.name and application.version: your app and version from step 3.

  • allowed_cors_origins: every address that serves your WebGL build. The example already lists http://localhost:8080. The browser calls the matchmaker directly, so other origins are blocked.

In the dashboard, open Matchmaker, select Create Matchmaker, upload the file and select Create and Start. When it's ONLINE, copy the API URL and Auth Token into Base URL and Auth Token on TanksMatchmakingClient (on the EdgegapMatchmaking object).

Build for Web in File → Build Profiles, then serve the build folder from an allowed origin:

python -m http.server 8080 --bind 127.0.0.1

Open http://localhost:8080 in two browser windows and click Find Match in each. Bring each window to the front before clicking: background tabs slow Unity WebGL down. Both windows land on the same Edgegap server. A single player gets a server alone after 30 seconds, which helps for testing.

5. Add it to your own Mirror WebGL game

The sample is a working reference: your coding agent can copy its tested files instead of writing them from scratch. These changes make a Mirror WebGL game run with Edgegap's matchmaker:

  1. WebSockets on a fixed port. SimpleWebTransport on port 7778, SSL off on the server, wss on the client. Headless Start Mode set to Auto Start Server, and the game scene enabled in Build Settings (the sample's MirrorTanks scene).

  2. A matchmaking client. Creates a ticket, waits for its server, then connects to wss://{host name}:{external port} with retries (Assets/EdgegapMatchmaking/TanksMatchmakingClient.cs). Latency beacons stay off in the browser.

  3. A server that stops itself. Stops the deployment when nobody joins or everyone has left, so billing stops (Assets/EdgegapMatchmaking/TanksMatchmakingServer.cs).

  4. SDK and stripping. Edgegap Unity SDK 3.5.5 or newer (older versions fail the WebGL build), and link.xml for IL2CPP.

  5. A matchmaker configuration with no latency rule and your origins in allowed_cors_origins (matchmaker-config.json).

Then upload the server with a WS port and TLS Upgrade, as in step 3.

With your agent:

"Load the edgegap skill, then edgegap-unity. Using github.com/edgegap/netcode-game-sample-webgl-mirror-tanks as the reference, make my Mirror game a WebGL dedicated-server game on SimpleWebTransport port 7778, add the matchmaking client and the server self-stop from its Assets/EdgegapMatchmaking folder, and generate a matchmaker configuration with no latency rule and my web origins in allowed_cors_origins."

For each step in detail, by hand, see the Mirror Networking integration guide, and the Unity WebGL guide for the browser-specific parts.

6. How the matchmaker places players and stops servers

The sample's tanks-webgl profile is built for the browser:

  • Match size: one team of 2 to 4 players. After 30 seconds in the queue, the minimum drops to 1, so you can test alone. Remove that expansion for a real game.

  • No latency rule. Browsers can't send the pings that desktop games use to measure latency. The matchmaker places the server from the players' public IPs instead.

  • Allowed origins. allowed_cors_origins lists the pages allowed to call the matchmaker. Add your real host, for example your itch.io page, before you publish.

  • Abandoned tickets. Browsers can close a tab without telling the game, so an unmatched ticket expires on its own after 5 minutes.

The Auth Token ships in the client build, as with any game using the matchmaker. It gives no access to your Edgegap account.

The server stops its own deployment, which ends billing:

  • 30 seconds after the last player leaves;

  • when nobody joins within 2 minutes.

When you upload a new server build, update application.version in the matchmaker (Stop, Edit, Start), or matches keep deploying the old build. Step 6 of the Unity WebGL guide covers the matchmaker in detail.

Known limits

  • Matchmaking is off by default. Out of the box, the sample has no SDK and the EdgegapMatchmaking object is inactive. Follow step 2 to turn it on.

  • The match never ends on its own. Tanks has no rounds or winner, so the server only stops when it's empty. For your own game, stop the deployment when the match is over.

  • No latency-based placement in the browser. Servers are placed from player IPs. The client script can measure latency in desktop builds with a latencies rule in a separate profile: written but not tested.

  • The solo expansion is for testing. With the example profile, a player who waits 30 seconds plays alone.

What was tested

Tested end to end on Edgegap, twice, before 15 October 2026 (the sample's pull request #1, merged that day), on Unity 6000.3.11f1:

  • Full loop: two WebGL clients served from http://localhost:8080, a live matchmaker, and an app version with WS and TLS Upgrade on port 7778. Both clients were matched, connected over wss:// to the deployment's external port on the first attempt, and the server stopped itself after both left.

  • Matchmaking off (default): the scene loads with no missing scripts, and the WebGL and Linux server builds succeed.

  • Matchmaking on (SDK 3.5.5): the WebGL and Linux server builds succeed. Run outside Edgegap, the server logs "Not running on Edgegap, self-stop disabled" and keeps serving.

Not tested: desktop clients with latency beacons, and hosting the WebGL build on itch.io with this sample.

Frequently Asked Questions

Questions about running Mirror's Tanks sample in the browser with Edgegap.

Can a Mirror WebGL game use matchmaking?

Yes. Edgegap's matchmaker works from the browser: the client sends a ticket, the matchmaker starts a dedicated server near the players, and each client connects over wss://. List the pages that serve your game in allowed_cors_origins, and leave out the latency rule.

Which Mirror transport works in the browser?

SimpleWebTransport. The Tanks sample runs it on port 7778, with SSL off on the server and wss on the client. On Edgegap, set that port to WS with TLS Upgrade on, and Edgegap handles the certificate.

Why is matchmaking off in the Tanks sample?

So the sample opens and builds without extra packages. Install the Edgegap Unity SDK (3.5.5 or newer), then activate the EdgegapMatchmaking object in the MirrorTanks scene. Deactivate it to turn matchmaking off again.

Do Tanks servers keep running after a match?

No. The sample's server stops its own deployment 30 seconds after the last player leaves, or after 2 minutes if nobody joins, so you're not billed for empty servers.

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.