- Home /
Google Play Realtime Quick Match Fails
I'm developing a game using Google Play for realtime multiplayer. The plugin I used is the Google official one: https://github.com/playgameservices/play-games-plugin-for-unity.
Basically I followed every step based on the documentation. I'm able to sign in, post score and see the leaderboard. However, I failed every time creating a quick game. The console shows that after calling quickGame(), OnRoomSetupProgress(float percent) method was actually never called. It directly goes to OnRoomConnected(bool success) which fails every time.
I tried to create a quick game from invitation. I was able to see my friend list in Google Play UI, but I didn't receive any invitation and the game creation failed too. I really don't know what I did wrong.
Thanks in advance for any help I could get. My codes here:
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
using UnityEngine.SocialPlatforms;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.Multiplayer;
using System.Collections.Generic;
public class GP : MonoBehaviour, RealTimeMultiplayerListener{
const string learderboard="xxx";
const int MinOpponents = 1, MaxOpponents = 1;
const int GameVariant = 0;
// Variables for implementing interface
public bool m_roomLoaded = false;
public bool m_peerConnected = false;
public float m_roomProgress = 0.0f;
public bool m_messageReceived = false;
public string m_message = "";
Invitation mIncomingInvitation = null;
// Use this for initialization
void Start () {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
// registers a callback to handle game invitations.
.WithInvitationDelegate(OnInvitationReceived)
.Build();
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
PlayGamesPlatform.Activate ();
Login ();
}
public void Login()
{
Social.localUser.Authenticate((bool success) => {
if(success)
{
print ("Success logged in");
}
else
{
print ("log in failed");
}
});
}
public void PostScore()
{
Social.ReportScore(12345, learderboard, (bool success) => {
if(success)
{
print("posted score");
}
else
{
print("post failed");
}
});
}
public void ShowLeaderboard()
{
PlayGamesPlatform.Instance.ShowLeaderboardUI(learderboard);
}
public void SignOut()
{
PlayGamesPlatform.Instance.SignOut();
}
public void quickGame()
{
PlayGamesPlatform.Instance.RealTime.CreateQuickGame(1, 1, 0, this);
}
public void inviteFriendGame()
{
PlayGamesPlatform.Instance.RealTime.CreateWithInvitationScreen(MinOpponents, MaxOpponents,GameVariant,this);
}
public void accept_inbox()
{
PlayGamesPlatform.Instance.RealTime.AcceptFromInbox(this);
}
// public void acceptInvitation()
// {
// //Invitation invitation = ....; // (obtained via delegate)
// PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitationId, invitation.InvitationId);
// }
// implement the realtime listener interface
public void OnRoomSetupProgress(float percent) {
m_roomProgress = percent;
print(m_roomProgress);
}
public void OnRoomConnected(bool success) {
m_roomLoaded = success;
if (success) {
print(“Success”);
} else {
print(“Error”);
}
}
public void getParticipantID()
{
Participant myself = PlayGamesPlatform.Instance.RealTime.GetSelf();
}
public List<Participant> getPlayerList()
{
List<Participant> participants = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants();
return participants;
}
public void OnLeftRoom() {
m_roomLoaded = false;
}
public void OnPeersConnected(string[] participantIds) {
m_peerConnected = true;
}
public void OnPeersDisconnected(string[] participantIds) {
m_peerConnected = false;
}
public void OnRealTimeMessageReceived (bool isReliable, string senderId, byte[] data)
{
throw new System.NotImplementedException ();
}
public void LeaveGame()
{
PlayGamesPlatform.Instance.RealTime.LeaveRoom();
}
public void OnInvitationReceived(Invitation invitation, bool shouldAutoAccept) {
if (shouldAutoAccept) {
// Invitation should be accepted immediately. Instance happens if the user already
// indicated (through the notification UI) that they wish to accept the invitation,
// so we should not prompt again.
ShowWaitScreen();
PlayGamesPlatform.Instance.RealTime.AcceptInvitation(invitation.InvitationId, this);
} else {
// The user has not yet indicated that they want to accept Instance invitation.
// We should *not* automatically accept it. Rather we store it and
// display an in-game popup:
mIncomingInvitation = invitation;
}
}
void ShowWaitScreen()
{
//To Do..
}
}
Have you tried adding in some debug code to get some feedback from whats going on?