question

Hans Weber avatar image
Hans Weber asked

Next step after finding a match

hello,

ich am sorry for the stupid question but I have just gotten started with playfab and have a small problem, that I am incapable of solving myself.

I am working on a turnbased 1v1 strategy game using unity and for networking mirror.

So far I have followed a video-tutorial series which unfortuntelly abruptly ends after establising matchmaking and I am not quite sure how to continue.

Right now I submit a ticket from my main menu and want the game to switch to the "GAME" scene once the match is found. At the same time the server is supposed to spin up and let both players connect. Is there a way to do this with Playfab, or is this rather a Unity connected question?

Title Datamultiplayer
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Made Wang avatar image
Made Wang answered

Referring to the steps in Matchmaking quickstart - PlayFab | Microsoft Docs, if you have hosted the server to PlayFab and enabled server allocation for the matchmaking queue, then when the match is successful, the player can call GetMatch to get the server's IP and port.

If you don't host the server to PlayFab then you need to manually start your server and connect the client to the server after the match is successful, this needs to be done by yourself.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hans Weber avatar image
Hans Weber answered

Thank you for the quick answer, I was tring this, but so far I get the first debug filled out, while unity doesn't receive anything for the IPV4Adress:

public void OnGetMatch(GetMatchResult _result)                                                          // get the data needed to connect the player ot the server and do so
{
    queueInfotext.text = $"{_result.Members[0].Entity.Id} vs {_result.Members[1].Entity.Id}";           // display who the player is up against

    Debug.Log("before IP: " + _result.ServerDetails.IPV4Address);
    PlayFabBattleClient.matchAddress = _result.ServerDetails.IPV4Address;                               // set the playfab object in the battle-scene up to be able to connect to the server
    
    Debug.Log("before Port" + (ushort)_result.ServerDetails.Ports[ 0 ].Num);
    PlayFabBattleClient.matchPort = (ushort)_result.ServerDetails.Ports[ 0 ].Num;
    
    Debug.Log("Player will be connected to ip: " + PlayFabBattleClient.matchAddress + ", Port:" + PlayFabBattleClient.matchPort);
    
    SceneManager.LoadScene( "Battle" );                                                                 // load the scene
}

Do you maybe know what the problem could be?

PlayFabBattleClient.matchAddress

and

PlayFabBattleClient.matchPort 

are on a sript in another scene where they will be read, to connect the player to the right match:

static public ushort matchPort = 0
static public string matchAddress = "";

Thank you for your help.

5 comments
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hans Weber avatar image Hans Weber commented ·

to be precise I get this error:

NullReferenceException: Object reference not set to an instance of an object
choseLoadouttoBattle.OnGetMatch (PlayFab.MultiplayerModels.GetMatchResult _result) (at Assets/Scripts/UI/choseLoadouttoBattle.cs:187)

Line 187 is the first Debug message:

Debug.Log("before IP: " + _result.ServerDetails.IPV4Address);
0 Likes 0 ·
Hans Weber avatar image Hans Weber Hans Weber commented ·

No, I think I have figured this out. I can't get a server back, when my build is unhealthy, right?

0 Likes 0 ·
Made Wang avatar image Made Wang Hans Weber commented ·

Right, you need to deploy the server to PlayFab correctly.

You will need to integrate your server with GSDK, and we recommend using LocalMultiplayerAgent to verify that the necessary integration has been done before deploying.

1 Like 1 ·
Show more comments
Show more comments

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.