Hi, I must be overlooking something very simple since I cannot find the answer anywhere and I'm doing everything as the manual tells me to. The problem is connecting two players in a 2 player turn based game. I am using the Unity3D api.
- I have succesfully uploaded my app and activated google play services.
- I can connect two phones with different accounts to the play services through my app.
- I can create a turn based game.
The problem is joining another player to the created game. Afaik this joining is automatically done by running PlayGamesPlatform.Instance.TurnBased.CreateQuickMatch(1, 2, 0, OnMatchStarted); on two different devices/apps. This is how I authenticate the player on the Play Services netwrok:
PlayGamesPlatform.Activate(); //Called on Awake() method.
public void SignIn() {
if (!PlayGamesPlatform.Instance.localUser.authenticated) {
PlayGamesPlatform.Instance.Authenticate ((bool success) => {
if (success) {
Debug.Log (PlayGamesPlatform.Instance.localUser.userName + " signed in.");
} else {
Debug.Log ("Failed to sign in!");
}
}, true);
} else {
Debug.Log(PlayGamesPlatform.Instance.localUser.userName + " already signed in!");
}
}
Both my accounts sign in without problems but when I start a match using CreateQuickMatch things start to go wrong. When a match gets created i imidiatly get the call back that the match is succesfully started. If I check the status of this TurnBasedMatch it returns active. But only one player joined it does not matter if minOpponents is 1 or 10.
private void NewGame() //Called on button click
{
PlayGamesPlatform.Instance.TurnBased.CreateQuickMatch(1, 2, 0, OnMatchStarted);
}
//Match callback
private void OnMatchStarted(bool succes, TurnBasedMatch match)
{
if (succes)
{
Debug.Log("Game succesfully started, waiting for players...");
TurnBasedHelper.match = match;
Debug.Log("Slots: " + match.AvailableAutomatchSlots); //Return == minOpponents
Debug.Log(match.Participants.Count + " players connected."); //Always returns one.
//Application.LoadLevel("GameScene");
}
else
{
Debug.Log("Game failed to start");
}
//Here match.status is already active.
}
Can't believe I cannot find any info to get me further. I simply need to join two players in a game. Hope somebody can explain what I'm doing wrong.
- I tried it from 2 different networks (my own and 4G)
- Increased/decreased min/max player count. This increases the available slots match.AvailableAutomatchSlots
- Obviously I am still testing, both accounts are supplied for testing in the services config.
- I activated TurnBased game in the services config.
- I can get leaderboards and achievements working.
- When Insalled on two devices and running this code, both will create a new match with only 1 player (self) in it.
I need some insight into where things go wrong.
- Is it normal the game goes into "Active" status immediately after creation?
- Do i need to setup PlayGamesClientConfiguration for the random matchmaking system:
.WithInvitationDelegate(OnInvitation)
.WithMatchDelegate(OnGotMatch)
.Build(); - Are there other things besides my code that could mess things up when I am connecting users to the playstore? Besides setting turn-based on in the developer console?
- Should this work when just pressing build and run with the android devices hooked up?