Sign In Register

How can we help you today?

Start a new topic
Answered

Matchmaking custom attributes

Hello,


I implemented matchmaking, following the tutorial : https://docs.gamesparks.net/tutorials/how-to-match-players

It works well, but I d like to know if there is a way to add some information in the MatchmakingRequest and get that back in the MatchFoundMessage ? (I m in Unity if that make any difference)


My game use synchronous Multiplayer, and I d like to add some information about the players connectivity and system to determine which player would be the "best" master client for the game (low ping with the game server, fast system, etc..).


Best Answer
Hey Simon,

It sounds like the MatchFoundMessageResponse might be what you are looking for.
You can send back your own custom script-data there. Something to note is that with the global version of that response you wont have access to the player.
Unfortunately you cannot attach script-data to the SparkMatch object itself, so you may have to get creative with how you gather the data so it is on-hand in the MatchFoundMessageResponse.

Hope that helps,
Sean

 


Answer
Hey Simon,

It sounds like the MatchFoundMessageResponse might be what you are looking for.
You can send back your own custom script-data there. Something to note is that with the global version of that response you wont have access to the player.
Unfortunately you cannot attach script-data to the SparkMatch object itself, so you may have to get creative with how you gather the data so it is on-hand in the MatchFoundMessageResponse.

Hope that helps,
Sean

 

I'm also a bit stuck on how to do this. I need a similar solution wherein I need to get participant's IP address and other information (such as port number) and add these info into the match found response message...


Did anyone ever get a running solution for this? 


My workaround was ultimately to write cloud code for the MatchFoundMessageResponse. What it does (and hopefully will do, lol..) is to:

1) Get player ID of the first participant in the participant list

2) Add a scriptData object to the response (e.g. { host = selected player id })


This way, at least the other 'non-selected' players would simply pass in their system information to the 'host' player... really ugly solution if you ask me, but it's probably one-step to getting my setup working.

Hey Lee,

You could pass the ip and port in from the client when a player authenticates, so that, while they are online their player script-data has a record of this.
Then when the match is done you can use Spark.LoadPlayer(playerID).getScriptData(ip) and attach that player data to the response.

Would this work for you?
Sean

 

Hi Sean! That sounds like a great idea! Just a clarification: I noticed that in Unity, a previously logged in player is automatically logged in/authenticated the next time I run the editor. With your suggestion, would that mean I need to re-authenticate a player after the initial automatic process I just described? Thanks and regards, Lee
Login to post a comment