Search code examples
google-play-servicesmultiplayergoogle-play-games

Custom matchmaking using Google play game services


I use GPGS for realtime multiplayer in a game I am developing. I can connect to other users just fine, but I was wondering: is there was a way to set a criteria for who you get auto matched with? For example , could I match players based on their levels or some other criteria like win/loss ratio? As of right now it is completely random and I don't think it offers a very good user experience.


Solution

  • Yes, there is. When you create your RoomConfig for match making you can provide AutoMatchCriteria. The API just uses a bitmask, so it is up to you what data you put in that bit mask:

    createAutoMatchCriteria

    exclusiveBitMask: Exclusive bitmasks for the automatching request. The logical AND of each pairing of automatching requests must equal zero for auto-match. If there are no exclusivity requirements for the game, this value should just be set to 0.

    You can see it being used in the sample code here: Developing Real-Time Multiplayer Games.