Turn-based matchmaking not working in iOS 10

蹲街弑〆低调 提交于 2019-12-08 03:16:43

问题


My game was working fine before iOS 10. Now, everyone with iOS 10 can't invite and play with who they want.

When a user says they want to play multiplayer, I create a GKMatchRequest like this:

GKMatchRequest *request = [[GKMatchRequest alloc] init];
request.minPlayers = 2;
request.maxPlayers = 4;
request.defaultNumberOfPlayers = 2;

I use a GKTurnBasedMatchmakerViewController to handle the invitation, etc. The user sees an interface that would let them change the number of players in the match and invite players. Let's say that they only want 2 players, so they leave that and they want to play with their friend. So, they use the interface to send an invite to their friend. The result, is that didFindMatch is called on my delegate with a GKMatch that has 4 participants. It should only have 2! The first participant is the local player and the other 3 have the status "Matching". So, their friend isn't even in the list. Does anyone have any suggestions for fixing this? This same code works fine in versions of iOS before iOS 10.


回答1:


It appears that with IOS10, the defaultNumberOfPlayers isn't being honored.

Keep in mind that GKTurnBasedMatch has three types of players in a given match:

  • The Originator who creates the match
  • Players that were specifically invited into the match
  • Players that automatch into the match

If you look at the player status for all 4 players in the match (using your example), I suspect you will see the following results

  1. Active (the originator)
  2. Invited (the 1 person you invited)
  3. Matching
  4. Matching

If so, that would indicate that defaultNumberOfPlayers was ignored, and the match was created with a max of 4 players (1 originator, 1 invitee and 2 automatch slots).

The workaround seems to be to set the maxNumberOfPlayers to the desired cap, in this case, 2, when you create the match.



来源:https://stackoverflow.com/questions/41916413/turn-based-matchmaking-not-working-in-ios-10

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!