
How to Add Automated, No-Code Matchmaking to Any Unity Multiplayer Game
The following is based on our Matchmaking SDK for Unity's documentation. Make sure to refer to our documentation for the latest.
We will cover every step to add matchmaking to a Unity multiplayer game using Edgegap's free Matchmaking SDK for Unity. Import a ready-made example and get a basic matchmaker functional in minutes. Grouping players and spinning up a server for each match automatically, anywhere in the world. The on-screen example uses Mirror Networking's Tank sample, but the approach is netcode-agnostic and works with Mirror, Fish-Networking, Unity's Netcode for GameObjects, and more.
This guide picks up right where the dedicated server tutorial leaves off. It assumes you have already built, containerized, and deployed your game server on Edgegap, and that you have an application with a version live on the platform. If you haven't, complete that tutorial first.
Let's get started!
The Edgegap plugin used in the dedicated server tutorial handles building and deploying your game server. Matchmaking is a separate package, named "Edgegap Unity SDK," and is installed on its own.
In Unity, from the top navigation bar, select Window, then Package Management, then Package Manager. Select the plus icon, then "Add package from git URL". Paste the SDK's URL (see below) and select Add.
https://github.com/edgegap/edgegap-unity-sdk.git
After a few seconds, the Edgegap SDK appears in your package list alongside the hosting plugin.
Next, import the example to work from. Still within the Package Manager, open the Samples tab, find the "Matchmaking - Simple Example," and import it. This copies a few scripts into your project under the Samples folder. Only the Matchmaking Simple Example is needed, so leave the others.
The SDK handles the heavy lifting: it measures each player's ping to a set of beacons, creates a matchmaking ticket for each player, waits until a server is assigned, and connects the matched players. It leaves one deliberate gap — the exact line that tells your game to connect to the assigned server. That line depends on your netcode, so the SDK cannot write it for you.
To fill that gap quickly, use a universal prompt that any AI coding assistant can run. It works in two parts: first the assistant audits the project to find how your game and netcode currently connect to a server, then it adds the matchmaking connection. Both prompts are netcode-agnostic.
Prompt 1 — audit the 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. Give file paths and line numbers. Do not change anything.
For the Mirror Tank sample, the audit confirms the client connects by calling StartClient() on Mirror's NetworkManager, with the address set via NetworkManager.singleton.networkAddress and the port set on the active PortTransport — in this case the KCP transport on port 7777.
Prompt 2 — add the connection:
In the Edgegap sample MatchmakingClientHandler.cs, find the block that runs when the ticket status is "HOST_ASSIGNED". It currently only logs the assignment. Replace that placeholder with code that connects to the assigned server using my netcode: read the assigned server's FQDN and set it as the network address, read the external port (it is a string — convert it to the type my transport expects) and set it on the active transport, then start the client connection. Use the connection method, address field, and transport port you identified in the previous step. Return the full updated block.
The assistant reads the project, identifies the netcode, and adapts the connection to it. The same approach works for other netcodes — the audit and edit adapt to whatever connection method the project uses. The one exception is a project that routes connections through its own custom networking layer rather than calling the netcode directly; the audit will flag that, and you can prompt the assistant to adapt the edit accordingly.
Part 3 - Connect the Handler to Your Scene
In your game scene, create an empty object: from the menu, select GameObject, then Create Empty. Rename it "Matchmaking." With the object selected, in the Inspector, select Add Component and add the Matchmaking Client Handler.
Two fields need to be filled: Base URL and Auth Token. Both come from the matchmaker, created next. Leave every other setting at its default.
Part 4 - Create Your Matchmaker
On the Edgegap platform, select Matchmaker, then Create Matchmaker, and give it a name for your own reference, such as "quickstart-dev."
For the configuration, nothing needs to be written or pasted. Open the dropdown and select the Simple Example — a ready-made setup ideal for a two-player match, which suits the Tank game. Selecting it automatically fills in your most recently uploaded application and version. Confirm these are the application and version you intend to use; if you have several versions, select the right one now.
Two parts of this configuration are worth understanding, as they are the starting point for tailoring matchmaking later:
The match size rule sets how many players are needed — here, one team of two players.
The latencies rule has each player ping a set of shared beacons and groups players whose results are close enough to share a low-ping match. The server's location is chosen separately, based on where the grouped players actually are.
On submit, a warning may appear that the server image isn't cached. This is a reminder that a production release benefits from a cached image so servers deploy instantly; for testing it is fine, so select Continue. The matchmaker spins up on the free shared cluster — allow a few minutes to initialize, then up to five more for it to become reachable on the network.
Once it is online, open its details. Copy the API URL and, back in Unity, paste it into the Matchmaking object's Base URL field. Do the same for the Auth Token.
This token only grants access to your matchmaker and nothing else on your account, so it is safe to keep in the client during development — no backend needed. In production, you would typically keep this token on your own backend instead. Not to hide the token, since it is matchmaking-scoped and safe, but so players authenticate to your backend first, letting you enforce identity, bans, and skill-based matching before a ticket is ever created.
Simulate two players using Unity's Multiplayer Play Mode (covered in the dedicated server tutorial), then enter Play mode.
The matchmaker finds enough players, groups them into a match, and deploys a fresh game server for them in the region closest to the group. Once the server is ready, it hands each player the address and port, and the connection code connects them automatically. Both players connect to the same on-demand dedicated server without anyone typing an address, and each player's tank is replicated in the other's window.
When building for production, note that a freshly assigned server may still be starting up for a brief moment after a match is found. Optionally, have the assistant add a basic connection retry to cover that gap; a separate, optional retry prompt is available in the documentation. The exact result depends on your netcode, but it is a useful starting point.
The Simple Example keeps things easy, but most games will require custom logic. There are two next steps.
First, explore the matchmaking example that fits your game type. The documentation has ready-made configurations for cooperative games, competitive games with skill-based matching, social games, custom lobbies, and backfill (which lets players keep joining a match already in progress).
Then, once you've picked the closest example, learn what each rule and parameter does so you can fully tailor the matchmaker to your game — team sizes, maps, skill ranges, and more.
You can also join our community on Discord to ask our dev team and other studios for help adapting your matchmaker.
Part 7 - The Code: What to Add and Why
This optional deep dive covers the code change the AI assistant made. These few lines are specific to the sample project, but the idea is universal for any netcode: take the address and port the matchmaker provides, hand them to your networking system, and connect. The exact names here — Mirror's NetworkManager, its transport, and the StartClient() call — are specific to Mirror Networking; the structure is identical regardless of netcode, so review your own netcode's documentation for the equivalents.
The only file to edit is the Matchmaking Client Handler. The other two files — the server handler and the custom ticket request — can be ignored for this basic setup.
The single block that changes is the one that runs when a server has been assigned and the ticket status becomes HOST_ASSIGNED. Out of the box, the sample only logs the server's details:
csharp
By default this prints the server's details to the console but does not connect, because how you connect depends on your netcode. Replace it with:
csharp
When a server is assigned, the matchmaker returns two things that matter: the server's address and the port to connect to. The code reads the server's address (its FQDN) and the external port (the port players actually reach the server through), hands the address to Mirror's NetworkManager and the port to Mirror's transport — converting the port from text to a number with Parse, since Mirror expects a number — then starts the client, which connects the player using the address and port just set. That is the whole change: one block, in one file.








