Discover how Edgegap works

Discover how Edgegap works

/

Unity Matchmaking SDK

Unity Matchmaking SDK

Deploy to Edgegap

Published

Published

Published

Last reviewed for accuracy

Last reviewed for accuracy

Last reviewed for accuracy

Unity Matchmaking SDK: How to add Matchmaking to your Unity multiplayer game with Edgegap

Unity Matchmaking SDK: How to add Matchmaking to your Unity multiplayer game with Edgegap

This guide shows you how to add matchmaking to a Unity multiplayer game that already runs on Edgegap's dedicated game servers: players select Find Match, get grouped by your rules, and connect to a server Edgegap starts near them.

Once your game server is containerized, Edgegap deploys it worldwide to 615+ Edge Cloud locations (on-demand) from a simple API call and billed exclusively on usage: no entire server to rent, provision or keep running between matches. For persistent servers of reserved capacity, Edgegap offers Private Fleets. Edgegap's Matchmaking builds on top of that and is optional.

Edgegap's matchmaker is a hosted service: no backend to write or run. It works with any netcode. Only the line that connects a player to the assigned server depends on yours.

This guide covers:

  1. Preparing a working Edgegap app version for your game

  2. Connecting your coding agent to Edgegap (optional)

  3. Installing Edgegap's Unity SDK

  4. Adding the matchmaking client to your game

  5. Creating your matchmaker

  6. Choosing your matchmaking rules

  7. Testing with two players

You can do it two ways, and mix them:

  • With a coding agent. Connect Claude Code, Cursor or another agent to the Edgegap MCP server and its agent skills. The agent adds the matchmaking client and the code for your netcode, generates the matchmaker configuration and checks the results. You handle the clicks in Unity and the Edgegap dashboard, and playtest.

  • By hand. Every step below also works without an agent, starting from the SDK's ready-made example.

Here, we use Mirror's Tanks example. Any Unity netcode works the same way.

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.

Step-by-Step Guide

Detailed Integration Steps

1. Before you start

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

  • A working Edgegap app version of your game server: a server you deployed and joined at least once. Matchmaking deploys the requested version for every match, so it needs a functional, containerized game server to work end to end. If you don't have one yet, use our guides:

  • Your server stops itself when the match ends, so you only pay while players play. The guides above cover it.

  • For the agent path: an Edgegap API token, from Dashboard → User Settings → Tokens. It is organization-wide, so treat it like a password: never put it in your project, your game client or a chat.

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 SDK. macOS usually has one already (Xcode Command Line Tools); on Windows, install Git.

2. Connect your coding agent to Edgegap

Skip this step if you're doing everything by hand.

The Edgegap MCP server lets your agent create apps and versions, deploy servers, read logs and generate matchmaker configurations on your account. The agent skills give it the tested Unity matchmaking client, the code for your netcode and the known pitfalls.

Claude Code (run in your own terminal, so the token never passes through the chat):

claude mcp add --transport http edgegap https://mcp.edgegap.dev/mcp -H "Authorization: token YOUR_EDGEGAP_API_TOKEN" --scope user

Then install the skills: /plugin marketplace add edgegap/edgegap-agent-skills, then /plugin install edgegap@edgegap. Restart the session.

Cursor, VS Code and other clients that send headers: add https://mcp.edgegap.dev/mcp with the header Authorization: token YOUR_EDGEGAP_API_TOKEN, and install the skills with npx skills add edgegap/edgegap-agent-skills --skill "*".

Claude Desktop: custom connectors can't send the header, so use the local server instead (Node 18+): { "mcpServers": { "edgegap": { "command": "npx", "args": ["-y", "@edgegap/mcp"] } } }. It asks for the token on first use.

Check it works:

"List my Edgegap apps."

Your app and its version should be in the list.

3. Install Edgegap's Unity SDK

Here's our video tutorial of Edgegap's Matchmaking SDK for Unity, from install to two players matched, using Mirror's Tanks example:

Edgegap's Unity SDK is the matchmaking package. It's separate from the plugin that builds and deploys your server.

With your agent:

"Load the edgegap-unity skill and install the Edgegap Unity SDK in this project, version 3.5.5 or newer."

Using FishNet or PurrNet? Ask your agent to load edgegap-fishnet or edgegap-purrnet instead, in this step and the next.

By hand:

  1. In Unity, select Window → Package Management → Package Manager, select +, then Add package from git URL, paste https://github.com/edgegap/edgegap-unity-sdk.git and select Add.

  2. In the SDK's Samples tab, import Matchmaking - Simple Example. You only need this one.

The SDK measures each player's ping to Edgegap's beacons, creates the matchmaking ticket, and waits until a server is assigned. It leaves one gap on purpose: the line that connects the player to that server, because it depends on your netcode. Step 4 fills it.

4. Add the matchmaking client to your game

With your agent:

"Add the edgegap-unity matchmaking client and server lifecycle scripts to my network scene, fill in the netcode adapter for my netcode, and wire my Play button to FindMatch. Leave the matchmaker URL and token empty for now."

The agent adds a Find Match panel you can use right away, connection retries for servers that are still starting, and the server code that stops each match's server when it ends. If your server image changes, it rebuilds it and creates a new app version.

By hand, with two prompts for any AI coding assistant, or your own code:

Prompt 1, audit your project (read-only):

"Read-only, no code changes. My Unity project uses a netcode framework and I'm adding Edgegap matchmaking, which will give my client a server address (an FQDN) and an external port at runtime. Find and tell me: 1) the method that starts a client connection to a server, the file and line, and what triggers it; 2) where the server address and the port are set before connecting: the exact property or field names, the transport in use, and the file and line. Do not change anything."

Prompt 2, add the connection:

"In the Edgegap sample MatchmakingClientHandler.cs, find the block that runs when the ticket status is HOST_ASSIGNED. It only logs the assignment. Replace it with code that connects to the assigned server with my netcode: set the assignment's FQDN as the network address, convert the external port of gameport to the type my transport expects and set it on the transport, then start the client. Use what you found in the previous step."

Then, in your game scene, select GameObject → Create Empty, name it Matchmaking, and add the Matchmaking Client Handler component. Leave Base URL and Auth Token empty for now: they come from step 5.

With Mirror, the connection sets NetworkManager.singleton.networkAddress to the FQDN, sets the port on the active transport, and calls StartClient(). Other netcodes use their own names for the same three things.

5. Create your matchmaker

  1. In the dashboard, open Matchmaker, select Create Matchmaker and name it, for example mygame-dev.

  2. Pick a configuration:

    • Quickest: select Simple Example in the configuration list (what it contains): one team of two players, grouped by latency. It fills in your latest app and version: check they're the ones you want.

    • With your agent: "Generate an Edgegap matchmaker configuration for my app version: one team of 2 to 4 players, and let a lone player get a server after 30 seconds so I can test alone. Save it as matchmaker-config.json." Then upload the file.

  3. Select Create and Start. A warning that your server image isn't cached is fine for testing: select Continue. Allow a few minutes for the matchmaker to start, and up to 5 more before its address answers.

  4. When it's ONLINE, copy the API URL and Auth Token into your matchmaking component (Base URL and Auth Token), or give them to your agent.

The Auth Token only gives access to your matchmaker, nothing else on your account, so it's safe in your game client. In production, many studios have players sign in to their own backend first, which creates the tickets, so they can check identity and bans before matching.

6. Choose your matchmaking rules

Run the step 7 test with your first configuration, then tailor the rules to your game. Each rule groups players by one thing:

  • Match size: how many teams and players per team.

  • Latency: players ping Edgegap's beacons and get grouped with players close to them. Edgegap then starts the server near the group.

  • Skill, mode, map or region: a number range or a value players must share.

  • Expansions: relax a rule after a wait, for example accept fewer players after 30 seconds, so nobody waits forever.

Two rules to remember:

  • Every rule except match size needs a matching value in each player's ticket, with the same name. A missing or extra value is refused (HTTP 400). Tell your agent when you add a rule, and it updates both sides.

  • WebGL games: browsers can't ping the beacons, so leave out the latency rule and list the sites that host your game under allowed_cors_origins. Use SDK 3.5.5 or newer.

Ready-made configurations for cooperative, competitive, social and custom-lobby games, and backfill (players joining a match in progress), are in the matchmaking documentation. Changing a running matchmaker's configuration reloads it and clears waiting tickets. When you ship a new server build, update application.version (Stop, Edit, Start), or matches keep deploying the old build.

7. Test with two players

  1. Make sure no test deployment is still running: the free tier runs one deployment at a time, and a leftover one blocks matchmaking.

  2. Run two clients: two Multiplayer Play Mode players, or the Editor plus a build.

  3. Select Find Match in both. The status goes from searching to match found, then both players connect to the same new server, with nobody typing an address.

  4. Leave the match. The server stops its own deployment, and it disappears from the dashboard.

A solo test only works if your configuration lets a lone player get a server (the 30-second expansion in step 5). On the free tier, the matchmaker stops 3 hours after each start: restart it from the dashboard, its URL and token stay the same.

Next Steps

Next Steps

Going live? Ask your agent to run the edgegap-launch skill's checklist, and pick a production matchmaker before launch. Prefer lobbies players browse? See the Server Browser for Unity. Already using Unity Gaming Services matchmaking? See UGS Matchmaker.

Stuck? Ask your agent to load edgegap-troubleshoot, or ask our team and other studios on the Edgegap Discord.

Frequently Asked Questions

Common questions about adding Edgegap matchmaking to a Unity multiplayer game.

Do I need my own backend for matchmaking in Unity?

No. Edgegap's matchmaker is a hosted service: your game client creates tickets with the matchmaker's Auth Token, and Edgegap starts a server for each match. Studios that want sign-in, bans or their own skill data before matching can create tickets from their backend instead.

Does Edgegap matchmaking work with Mirror, Netcode for GameObjects and Fish-Networking?

Yes. The matchmaker and the Unity SDK don't depend on your netcode. Only the code that connects a player to the assigned server's address and port changes, a few lines per netcode.

Is the matchmaker Auth Token safe in a game client?

Yes. It only lets clients create and read matchmaking tickets on that matchmaker. It gives no access to your Edgegap account, unlike your Edgegap API token, which never goes in a client.

Can I add matchmaking to a Unity WebGL game?

Yes, with Edgegap's Unity SDK 3.5.5 or newer. Browsers can't ping latency beacons, so the WebGL profile has no latency rule, and the matchmaker lists your game's web addresses under allowed CORS origins.

How much does Edgegap matchmaking cost?

Testing is free, on a shared matchmaker that stops 3 hours after each start. For a live game, you choose a production matchmaker, and game servers bill per vCPU per minute only while they run.

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

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

/ 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.0282

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