Prefer an all-in-one path? PlayFlow has native matchmaking with Unity SDK support — no UGS required. Use this guide when you specifically want to keep the Unity Matchmaker.
- You have a working UGS Matchmaker setup. Refer to Unity’s Matchmaker documentation for matchmaking topics.
- You have a PlayFlow project and an uploaded dedicated Linux server build. See Docker builds.
How it works
Matchmaker assembles a match
UGS Matchmaker groups players and invokes your allocator Cloud Code function with the matched player list.
Allocator starts a PlayFlow server
Your allocator calls
POST /api/v3/servers/start. PlayFlow reserves the ports immediately and returns the instance_id and network_ports.Allocator publishes the assignment
The allocator waits for the server to reach
running, then stores the host:port for the match (in UGS Cloud Save / your game data) keyed so the matched players can find it.Step 1 — Store your PlayFlow key as a UGS secret
In the Unity Cloud dashboard, under Administration → Secrets, add:PLAYFLOW_API_KEY— a PlayFlow server key (pf_...) from your project’s API Keys.
Step 2 — Region selection
Edgegap places servers from player IP addresses; PlayFlow takes an explicitregion instead (one of 13) — there is no IP-based placement.
Have each player attach a coarse location or preferred region as matchmaking ticket custom data, then pick a region in the allocator:
Attach region hint to the ticket
If you send lat/long instead of a region name, reuse the
nearestRegion() helper from the PlayFab Bridge guide to map the match’s average location to one of PlayFlow’s regions.Step 3 — The allocator
Deploy a Cloud Code function that the matchmaker calls when a match is assembled. Its PlayFlow responsibilities are:- Start a server with the matched players and chosen region.
- Wait until the server is
running. - Store the connection details so clients can look them up.
Allocator (Cloud Code) — PlayFlow calls
{ host, port, instanceId } against the match (UGS Cloud Save, a database, or the matchmaker’s assignment results) so the matched players — looked up by UGS_PLAYER_IDS — can retrieve it.
For the UGS-side contract — how your allocator is registered, invoked by the matchmaker, and how assignment results are returned to clients — follow Unity’s official hosting-providers allocator template. This guide only covers the PlayFlow calls that go inside it.
Step 4 — Retrieve the assignment on the client
Clients fetch their assignment (via the matchmaker’s standard assignment flow or by reading the game data your allocator wrote), then connect their transport tohost:port:
Connect once assigned
Step 5 — Clean up
When the match ends, terminate the server so you stop paying for it:Terminate the server
PLAYFLOW_API_KEY, PLAYFLOW_API_URL, and PLAYFLOW_INSTANCE_ID into the container, so your headless build can call DELETE /v3/servers/$PLAYFLOW_INSTANCE_ID when the last player disconnects. Setting a ttl at start time guarantees cleanup even if nothing calls delete.