Procedure
This guide will walk you through the steps of using Unity's Matchmaker to match players through Relay. You will learn how to integrate Matchmaker with Relay and use the Lobby service for a seamless multiplayer session.
Detailed Procedure
Initial Setup
1. Install the Matchmaker SDK
- Go to the Unity Package Manager.
- Add the com.unity.services.matchmaker package to your project.
2. Configure Matchmaker in Unity Cloud Dashboard
- Visit cloud.unity.com.
- Navigate to Products > Multiplayer > Matchmaker and select Launch.
- Create a Queue and a Pool.
- Select Relay as your hosting type during the pool setup.
Creating and Polling Matchmaking Tickets
3. Create a Matchmaking Ticket
- Use the Matchmaker SDK or API to create a matchmaking ticket. This requests Matchmaker to find and allocate a Relay server for your players.
4. Poll for Ticket Status
- Continuously check the status of your matchmaking ticket.
- Determine when a match has been found and a Relay allocation has been made.
Integrate Lobby Service
5. Add the Lobby Package
- Open the Unity Package Manager.
- Install the Lobby package into your project.
6. Obtain MatchIdAssignment
- After creating a matchmaking ticket, receive a MatchIdAssignment.
- Use this Match ID to send a CreateOrJoin request to the Lobby service.
Configuring Relay in Lobby
7. Set Up the Host
- The host (one of the players) keeps the lobby alive by sending heartbeats.
- The host requests a Relay allocation and generates a Relay join code.
8. Distribute Relay Join Code
- Use the Lobby service to share the Relay join code with other players.
- Players use this join code to connect to the Relay server.
Additional Configuration
9. Transition Players
- Implement the logic to transition players from the matchmaking phase to the lobby phase using the provided Match ID.
Resources
- Unity Lobby Documentation: Unity Lobby Docs
- Unity Relay Documentation: Unity Relay Docs
- Matchmaker Integration Guide: Matchmaker Guide
If you encounter any issues or have further questions, please feel free to reach out for assistance via portal.