I’m used to use the Lobby System along with Relay to create matches, I was wondering if the new matchmaking is only made to be used with the Multiplay system? From the documentation, I haven’t found any reference on how to use it with Relay.
Thanks
I’m used to use the Lobby System along with Relay to create matches, I was wondering if the new matchmaking is only made to be used with the Multiplay system? From the documentation, I haven’t found any reference on how to use it with Relay.
Thanks
If you go to the first message in this forum, in the requirements section, it says machmaker is only avaliable for multiplay users
Hi Max_power1965, this is Gladys, product manager of the Matchmaker solution. While Matchmaker currently requires Multiplay, we plan to support Relay sometime next year. Please see our roadmap below for more details:
Hello good day, is matchmaking now compatible on unity relay? I was planning to use relay for my startup multiplayer game and integrate matchmaking.
Hello @A_zazel !
Yes, Matchmaker is now compatible with Unity relay, take a look at matchmaker documentation.
https://docs.unity.com/ugs/en-us/manual/matchmaker/manual/get-started
Matchmaker is indeed compatible with Relay.
You might also want to take a look at our new Multiplayer Services SDK (here is the documentation: Multiplayer Services sessions for the Unity Engine). It bundles the standalone SDKs for Lobby, Relay, Matchmaker and Game Server Hosting for easier use.
Finding a session can be as easy as this example (based on Matchmaking into a session)
var matchmakerOptions = new MatchmakerOptions { QueueName = "Friendly" };
var sessionOptions = new SessionOptions() { MaxPlayers = 2 }.WithRelayNetwork();
var matchmakerCancellationSource = new CancellationTokenSource();
var session = await MultiplayerService.Instance.MatchmakeSessionAsync(matchmakerOptions, sessionOptions, matchmakerCancellationSource.Token);
Please take into account that
preview (1.0.0-pre.1 at the time of this reply). We are currently looking for feedback both on the SDK usage (how easy it is to use, if you find use cases not covered, …) and the documentation (how clear it is, how easy it is to get started, …).Hello @ArthurAtUnity ,
I’m using the Unity version 2022.3.25f1, and I’m unable to find the package com.unity.multiplayer.widgets nor the package Multiplayer Play Mode.
And I cannot upgrade the project to Unity 6 since my project is VR and I’m facing a lot of errors when trying to upgrade.
@ArthurAtUnity I’m still trying to implement Matchmaker with Relay, but I’m facing difficulties setting up Relay after the matchmaker ticket is found. How can I know who should be the host and create an allocation for all the players and communicate the join code?
I feel like I am missing something, and I didn’t find anything on the documentation regarding this part. Is there a sample scene or project showcasing the integration of matchmaking with Relay that I can take a look at?
@A_zazel Were you able to figure out this part?
I ended up upgrading to the Multiplayer services sessions package, and using it to create a matchmaking ticket with Relay, since the package handle everything regarding the host assignment and the joining the room.
I’m currently struggling with getting the matchmaking results after the match is found, calling session.GetMatchmakingResults(); throw an error, apparently there should be a matchmaker module registered in the session, however, the matchmaker module is not found, and therefore. the results of the matchmaking are inaccessible.
Did I miss something in the session creation?
public async void FindMatch(int MapId)
{
try
{
Debug.Log($"[Network] [Matchmaker Manager] Find Match! map id: {MapId}");
var matchmakerOptions = new MatchmakerOptions
{
QueueName = DEFAULT_QUEUE,
PlayerProperties = new Dictionary<string, PlayerProperty>() {
{ "PlayerName", new PlayerProperty("Player X")},
{ "MapId" , new PlayerProperty(MapId.ToString())}
}
};
var sessionOptions = new SessionOptions() { MaxPlayers = 4 }.WithRelayNetwork();
matchmakerCancellationSource = new CancellationTokenSource();
matchmakerCancellationSource.CancelAfter(40000);
session = await MultiplayerService.Instance.MatchmakeSessionAsync(matchmakerOptions, sessionOptions, matchmakerCancellationSource.Token);
StoredMatchmakingResults matchmakingResults = session.GetMatchmakingResults();
Debug.Log($"[Network] [Matchmaker Manager] Matchmaking results: {matchmakingResults}");
}
catch (Exception ex)
{
Debug.Log($"[Network] [Matchmaker Manager] Matchmaking failed {ex}!");
}
}
Hi @Zaimes4,
I apologize for the late reply, I’ll reply to your messages in order.
com.unity.multiplayer.widgets is indeed only available for Unity6, however, the Multiplayer (Session) package is supported on all Unity versions 2022.3+.
After the matchmaker ticket is found, there is indeed a race condition to find which player will be the host and which one will be the client. There are multiple ways to resolve it and in the Multiplayer package, we use the Session concept (and Lobby’s CreateOrJoin under the hood) to decide on the host and client.
The documentation is indeed lacking on this part. Thank you for pointing it out! I will forward it to the relevant team.
You did not miss anything, it is indeed an issue on our end. Thank you (once more) for this feedback! A bug was created for us to prioritize. Can I ask you which information you need that you cannot find in the ISession ? Maybe we can find a workaround that can satisfy your requirements.
Thank you @ArthurAtUnity for your assistance here! Your guidance was a great help for me
to implement the networking in the project I’m working on.
I ended up using the Multiplayer Session Manager since it’s more suited for a flexible use of the different Unity multiplayer services.
Regarding the GetMatchmakingResults issue, I fixed it by simply getting the results direclty from the matchmaker service.
StoredMatchmakingResults matchmakingResults = await MatchmakerService.Instance.GetMatchmakingResultsAsync(session.Id);
I have a question regarding the MatchmakeSessionAsync call, if the matchmaking failed for a specific reason the async method doesn’t throw an error, that’s why I ended up using the cancellation token to automatically cancel the matchmaking if the duration bypassed what I’m setting for the queue in the Matchmaking service, I want to ask if there is a better way to handle matchmaking ticket failing.
matchmakerCancellationSource.CancelAfter(40000); // Automatically cancel the matchmaking after 40 seconds
I’m glad you managed to use the Matchmaker SDK to fetch the results.
Sorry about the MatchmakeSessionAsync confusion. The fix is implemented and scheduled for the next version of the package ![]()
MatchmakeSessionAsync will be throwing a SessionError when
SessionError.Error is set to SessionError.MatchmakerAssignmentTimeoutSession.Error is set to SessionError.MatchmakerAssignmentFailedHello, I’m using the matchmaker, lobby and relay packages.
I’m running into the same race condition described here, as to who should host a lobby and who should join a lobby.
At the moment, all the matchmaker gives me is a match id and nothing more. With that I cannot overcome the problem described above.
I’m not sure how you guys are using Lobby’s CreateOrJoin to solve this, because CreateOrJoin requires a lobby ID, which we do not have since we do not have a lobby; unless I’m misunderstanding how CreateOrJoin works.
I tried adding random delays when querying or creating the lobby, whereas clients will first wait a random amount of time, then query for a lobby that has the match id as its name, if not found then they create one with that name. This doesn’t always work due to the randomness of the wait time.
I feel the matchmaker needs to return more than just the match id, something that can help us decide which player should host a lobby.
Ideally we could include some metadata with our matchmaker ticket, for example we can include the client’s latency. Then we can have the matchmaker gives us the match id and the metadata that all the clients sent, in our case all their latencies. Then we could use that to decide who should host, for example the player with the best latency would host.
Your confusion about how CreateOrJoin has been heard! We will enhance the documentation around it. In fact, you do not need to provide CreateOrJoin with an existing valid Lobby ID:
In the Multiplayer SDK, we actually pass the match ID to CreateOrJoin for us to have a Lobby created with the same ID the Matchmaker match. I encourage you to do the same.
That being said, if you still need to pass data to the Matchmaker service, custom data can be sent along the player creation. The latencies are bundled with the match results (in the MatchmakingResults > MatchProperties> Player > QoSResult)
If you need custom logic using the latencies, the documentation is currently a bit fragmented, but you might be interested in
thanks for clarifying the use of CreateOrJoin, I adjusted my code and now it works properly ![]()
How can I get the MatchmakingResults? I’m using Relay, is that a Multiplay only option?
Hi @TheCaveOfWonders !
Glad to have been of help !
There are two ways today to access the MatchmakingResults:
MatchmakerService.Instance.GetMatchmakingResultsAsync (as mentionned by @Zaimes4 in a previous post). Since it bundles all Matchmaker, Lobby and Relay in a single package it might be a good fit for your game.Unfortunately, being able to fetch the MatchmakingResults from the Matchmaker standalone SDK is not in our roadmap so far. If using the Multiplayer SDK or fetching the result from the REST API are not viables solutions for you, I encourage you to submit an idea to help us gather feedback and review priorities.
Thank you, @ArthurAtUnity, for your reply! I am looking forward to the new version of the package to have the fix for throwing errors since I’m using a temporary solution to handle it.
It is out of topic, but I would like to ask if you know anything about host migration when using Relay, currently the session is completely dependent on the host; if he got disconnected everything is lost, and I was unable to fix a way to handle this problem.
@TheCaveOfWonders If you are looking for a standard matchmaking/lobby and relay integration, I highly recommend using the Multiplayer SDK. Everything is handled out of the box, from the matchmaking ticket to creating and joining the lobby.
Hey @Zaimes4 !
If you are using Netcode for GameObjects:
If you use Netcode for Entities, unfortunately we don’t offer any solution for host migration today however it is explicitly mentioned in our roadmap. There will be news about it in the next few months.
I am still not certain how you get from the session to actually connecting the host and clients and starting the NetworkManager when using Relay. The linked documentation is very sparse on the specifics.
Is a relay allocation done automatically or do we have to establish that manually? What relay APIs do we have to use as when I am trying to use any API from the Relay package I get conflicts between types being defined in two assemblies (like ‘JoinAllocation’ being a type in the Multiplayer Services and Relay package)?
Hi @Luxxuor ,
Thank you for your feedback on the documentation, it is still being worked on but knowing you want deeper understanding on how it works and what is required from you helps us structure it !
In terms of what the Multiplayer Services SDK does automatically compared to the previously existing SDKs, creating a session using CreateSessionAsync
var options = new SessionOptions { MaxPlayers = 2 }.WithRelayNetwork();
var session = await MultiplayerService.Instance.CreateSessionAsync(options);
We automatically:
The documentation for the migration is in progress and should be released under Multiplayer Services sessions for the Unity Engine in the following weeks. For most of the SDKs, the migration only involves