End Game a multiplayer Game
Options
Hello, I'm beginer with Photon and I am developing a multiplayer Pong game. I managed to develop the game and make the conditions for victory. But I'm looking
1) How to end a game properly by removing all players from a room and returning to the main menu (the player is disconnected from the server)
2) Return to the lobby while remaining connected to the master server, ready to search for a new game.
Can you help me perform the correct method please ?
1) How to end a game properly by removing all players from a room and returning to the main menu (the player is disconnected from the server)
2) Return to the lobby while remaining connected to the master server, ready to search for a new game.
Can you help me perform the correct method please ?
0
Comments
-
This is my code and it function well, but i have a message issue at the line ( PhotonNetwork.LeaveRoom())
In my debug console it say: Operation LeaveRoom(254) not called beacause client is not connected or not ready yet, client state: leavingvoid Update() { // Win condition if (scoreP1.score == scoreVictoire) { textVictoire.text = "Player 1 win"; finDePartie = true; StartCoroutine(EndGame()); } else if (scoreP2.score == scoreVictoire) { textVictoire.text = "Player 2 win"; finDePartie = true; StartCoroutine(EndGame()); } // lorsque la balle n'est plus en jeux et la partie n'est pas fini if (ballEnJeu == false && finDePartie == false) { SpawnBall(); ballEnJeu = true; } } public void SpawnBall() { GameObject ball = PhotonNetwork.Instantiate("BallOnline", spawnBallPoint.transform.position, Quaternion.identity); ballEnJeu = true; finDePartie = false; } // à la deconnexion de la salle, changement de scene et retour au menu principal public override void OnDisconnected(DisconnectCause cause) { Debug.Log("cause de la deconnexion: " + cause.ToString()); UnityEngine.SceneManagement.SceneManager.LoadScene(0);[s][/s] } public override void OnLeftRoom() { PhotonNetwork.Disconnect(); } private IEnumerator EndGame() { float timer = 5.0f; while (timer > 0.0f) { yield return new WaitForEndOfFrame(); timer -= Time.deltaTime; Debug.Log(timer); } PhotonNetwork.LeaveRoom(); Debug.Log("sortie de chambre"); } }
0