Player count , the holy grail of all Multiplayer online matches for Turn-based and Realtime Games has a few gotcha’s when it comes to Google Game Services ( GPG ) and Apple Game Center.
Before we go into details , some abbreviations i cooked up to make it cleaner to read 😉
GPG – GooglePlayGame Services
GC – Game Center
TB – Turnbased Match
RT – Realtime Match
minPlayers – the minimum player count to kickstart a match
maxPlayers – the maximum players allowed for a match
API – just a sample , please see the GPG and GC documentation online
For example lets create a match
|TB.CreateMatch(minPlayers,maxPlayers);||Does not count the player calling the API||Counts the player calling the API|
|RT.CreateMatch(minPlayers,maxPlayers);||Does not count the player calling the API||Counts the player calling the API|
As you can see the two API’s from Google and Apple do the same thing but can actually trip you if not careful!! The problem is that if you pass in for example
// one on one match for GPG would work fine for the same call
CreateMatch(1,1); // minPlayers = 1 & maxPlayers = 1 , for Game Center , WONT WORK
You are in for a treat..
GPG would go ahead and create a 2 player match ( does not count you ) , while Game Center would silently fail ( you cant play with yourself naughty boy , we control everything 😀 ) or in our case saw the matchmaker dialog do a fancy appear and hide . I was in for a surprise because i had experience creating TB and RT matches for GPG but GC was my first attempt.
So the right way for a 2 player match for GC would be
// One on One match for GC
CreateMatch(2,2); // minPlayers=2 and maxPlayer=2 for Game Center , WORKS
Spent several hours trying to figure out what was going on and turned out to be the player count dilemma that the 2 API’s have . Not sure who is correct , but surely can trip you.
p.s: There are other API’s in GC that fetch the players in a game excluding current player. Be wary of them too ;).
Hope this post helps the brave souls getting into Multiplayer using Google Play or Game Center services.Read More