fourthking
fourthking

Reputation: 331

GameSparks Manual Matchmaking

my team and I are building a game in Unity and are using GameSparks to implement networking into our game. We are trying to implement Manual Matching making so that when Matchmaking, GameSparks doesnt automatically match players for us. We want to control that ourselves.

So according to their docs, first we have to call for a MatchMakingRequest

new GameSparks.Api.Requests.MatchmakingRequest()
        .SetMatchShortCode("match_name")
        .SetSkill(0) // 
        .Send((response) => {
            if (response.HasErrors)
            { // check for errors
                    Debug.LogError("GSM| MatchMaking Error \n" + response.Errors.JSON);
            }
            else
            {
                    Debug.Log("MatchMakingRequest response: " + response.JSONString);
            }
        });

This will create a match with a match ID (for example the match ID of this newly created match would be 1). After we need to call FindPendingMatchesRequest.

new GameSparks.Api.Requests.FindPendingMatchesRequest()
      .SetMatchShortCode("MP_match")
      .Send((response) =>
    {
        if (response.HasErrors)
        {
                Debug.Log("Matchmaking error: " + response.Errors.JSON);
        }
        else
        {
                Debug.Log(response.JSONString);
        }
    });

Doing so, according to their docs is suppose to find a pending match, which in this case would be the match created with an ID of 1. However it creates a new pending match with an ID of 2 instead.

So for example, if two players are trying to play:

-Player 1 automatically calls MatchMakingRequest and creates a match with ID 1. But he also calls FindPendingMatchesRequest which creates a new match with ID 2.

-Player 2 now calls FindPendingMatchesRequest and instead of finding the matches with either ID 1 or ID 2, its creates a new match with ID 3.

This will continue to happen with every new player that looks for a pending match therefore they never join each others sessions.

So my question is how do I get FindPendingMatches request to actually find a pending match instead of create an entirely new one?

Upvotes: 0

Views: 500

Answers (1)

Rozx
Rozx

Reputation: 71

I think there are few things you got it wrong. First, the custom matchmaking logic is happening on server-side, which you can configure it on GameSpark -> Configurator -> Multiplayer -> Matches.

On there you can setup min/max player, thresholds(min, max waiting time), custom script and so. On custom script is the place you setup your manual matchmaking logic.

The reason happening on your side possibly because something wrong with your matches setup, you can refer here to see the tutorial:

https://docs.gamesparks.com/tutorials/multiplayer/matching-players.html#customizing-matching

Upvotes: 1

Related Questions