Hello i need help with detecting problem in my script…
The problem is when it goes to PlayGamesPlatform.Instance.RealTime.ShowWaitingRoomUI();
Then only flash WaitRoomUI and after one sec automatically exit can someone help me?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using GooglePlayGames;
using GooglePlayGames.BasicApi;
using GooglePlayGames.BasicApi.Multiplayer;
public class ControlScript : MonoBehaviour, RealTimeMultiplayerListener{
public float Speed;
public GameObject PlayerOne;
public Text PlayerOneText;
public GameObject PlayerTwo;
public Text PlayerTwoText;
public GameObject player;
// Use this for initialization
void Start() {
Authenticate();
}
// Update is called once per frame
void Update () {
if (player=PlayerOne)
{
//AccelerometerMoveOne();
string PlayerOneData = "PlayerOne" + ":" + PlayerOne.transform.position.x + ":" + PlayerOne.transform.position.y;
byte[] PlayerOneDataArr = System.Text.ASCIIEncoding.Default.GetBytes(PlayerOneData);
PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false,PlayerOneDataArr);
} else if (player = PlayerTwo)
{
//AccelerometerMoveTwo();
string PlayerTwoData = "PlayerTwo" + ":" + PlayerTwo.transform.position.x + ":" + PlayerTwo.transform.position.y;
byte[] PlayerTwoDataArr = System.Text.ASCIIEncoding.Default.GetBytes(PlayerTwoData);
PlayGamesPlatform.Instance.RealTime.SendMessageToAll(false, PlayerTwoDataArr);
}
}
void Authenticate() {
PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
.Build();
PlayGamesPlatform.InitializeInstance(config);
// recommended for debugging:
PlayGamesPlatform.DebugLogEnabled = true;
// Activate the Google Play Games platform
PlayGamesPlatform.Activate();
PlayGamesPlatform.Instance.Authenticate((bool success) => {
if (success)
{
CreateQuickGame();
}
else {
}
});
}
void CreateQuickGame() {
const int MinOpponents = 1, MaxOpponents = 2;
const int GameVariant = 0;
PlayGamesPlatform.Instance.RealTime.CreateQuickGame(MinOpponents, MaxOpponents,
GameVariant, this);
}
private bool IsRoomSetupped = false;
public void OnRoomSetupProgress(float progress)
{
if (progress>=20f)
{
IsRoomSetupped = true;
PlayGamesPlatform.Instance.RealTime.ShowWaitingRoomUI();
}
}
private bool connected = false;
public void OnRoomConnected(bool success)
{
if (success)
{
Participant myself = PlayGamesPlatform.Instance.RealTime.GetSelf();
List<Participant> participants = PlayGamesPlatform.Instance.RealTime.GetConnectedParticipants();
PlayerOneText.text = participants[0].DisplayName;
PlayerTwoText.text = participants[1].DisplayName;
if (myself.ParticipantId == participants[0].ParticipantId)
{
player = PlayerOne;
// Camera.main.GetComponent<CameraFollow>().setTarget(PlayerOne.transform);
}
else if (myself.ParticipantId == participants[1].ParticipantId)
{
player = PlayerTwo;
//Camera.main.GetComponent<CameraFollow>().setTarget(PlayerTwo.transform);
}
connected = true;
}
else
{
connected = false;
// ...show error message to user...
}
}
public void OnLeftRoom() {
connected = false;
}
public void OnParticipantLeft(Participant participant) {
}
public void OnPeersConnected(string[] participentIds)
{
}
public void OnPeersDisconnected(string[] participentIds)
{
Debug.Log("Dissconnected");
}
public void OnRealTimeMessageReceived(bool IsReliable,string SenderId,byte[] data)
{
string position = System.Text.Encoding.Default.GetString(data);
string[] raw = position.Split(new string[] { ":" }, System.StringSplitOptions.RemoveEmptyEntries);
if (!IsReliable)
{
//if (raw[0] == "ball")
// {
//ball.transform.position = new Vector2(System.Convert.ToSingle(raw[1]), System.Convert.ToSingle(raw[2]));
// Debug.Log("WHAT");
// }
if (raw[0] == "PlayerOne")
{
PlayerOne.transform.position = new Vector2(System.Convert.ToSingle(raw[1]), System.Convert.ToSingle(raw[2]));
}
if (raw[0] == "PlayerTwo")
{
PlayerTwo.transform.position = new Vector2(System.Convert.ToSingle(raw[1]), System.Convert.ToSingle(raw[2]));
}
}
}
}