I'm trying to do some basic Matchmaking with the Unity SDK but I can't find an example showing how to do single player matchmaking. I'm just trying to have one player connect to the matchmaking system on one client and then another player on a different client connect and have the two players matched up. The only example code I can find is here:
PFEntityKey entityKey = ...; // PlayFab user's entity key PFEntityKey remoteEntityKey = ...; // another PlayFab user's entity key string remoteUserAttributesJson = ...; // JSON string with another PlayFab user's attributes for matchmaking PlayFabMultiplayer.OnMatchmakingTicketStatusChanged += PlayFabMultiplayer_OnMatchmakingTicketStatusChanged; List<MatchUser> localUsers = new List<MatchUser>(); localUsers.Add(new MatchUser(entityKey, remoteUserAttributesJson)); List<PFEntityKey> membersToMatchWith = new List<PFEntityKey>(); membersToMatchWith.Add(remoteEntityKey); PlayFabMultiplayer.CreateMatchmakingTicket( localUsers, "QuickMatchQueueName", membersToMatchWith);
The above code seems to request a Matchmaking ticket for a group of players? I don't really understand what the "membersToMatchWith" list is for and I don't think I need it for 1v1, so I've tried the following instead:
// in the result from a successful call to LoginWithCustomID: PFEntityKey entityKey = new PFEntityKey(result.EntityToken.Entity.Id, result.EntityToken.Entity.Type); // and then I use this entity key to try to create a match ticket MatchUser localUser = new MatchUser(entityKey, userAttributesJSON); PlayFabMultiplayer.CreateMatchmakingTicket(localUser, "TestMatch");
but this gives me the following error in the Unity console:
"no PlayFab entity token was associated with the provided entity key. Use PFMultiplayerSetEntityToken to associate a PlayFab entity token with a PlayFab entity key before passing that entity key to the API"
I'm not sure what to do here because I'm very new to PlayFab and am still trying to get my head around EntityTokens and wotnot. @Brendan could you please point me in the right direction or give me some Unity example code for this? Thanks!