Start the Game Scene after all clients finished loading the game scene.
Hi,
I wanted to start the game level after all clients are completed loading the game level. And I wanted all clients can see other clients' loading progress. I think this could achivable using Photon events, but I don't see any option to tell the client wait after loading the level.
I wrote some code but I'm not sure I'm in wright way.
I wanted to start the game level after all clients are completed loading the game level. And I wanted all clients can see other clients' loading progress. I think this could achivable using Photon events, but I don't see any option to tell the client wait after loading the level.
I wrote some code but I'm not sure I'm in wright way.
private IEnumerator LoadGameLevelAsync() { PhotonNetwork.LoadLevel(gameArenaSceneIndex); while (PhotonNetwork.LevelLoadingProgress < 0.9f) { gameLoadingSlider.value = PhotonNetwork.LevelLoadingProgress; } yield return new WaitForSeconds(delay); loadingSlider.value = 1; RaiseEventOptions raiseEventOptions = new RaiseEventOptions { Receivers = ReceiverGroup.All }; SendOptions sendOptions = new SendOptions { Reliability = true }; PhotonNetwork.RaiseEvent(PhotonEvents.LoadingGameSceneCompleted, null, raiseEventOptions, sendOptions); } public void OnPhotonSerializeView(PhotonStream stream, PhotonMessageInfo info) { if (!PhotonNetwork.InRoom) return; if (stream.IsWriting) { stream.SendNext(gameLoadingSlider.value); } else if(stream.IsReading) { opponentGameLoadingSlider.value = (float)stream.ReceiveNext(); } } public void OnEvent(EventData photonEvent) { if (photonEvent.Code == PhotonEvents.LoadingGameSceneCompleted) { playersThatLoadLevel++; if (playersThatLoadLevel == PhotonNetwork.CurrentRoom.PlayerCount && PhotonNetwork.IsMasterClient) PhotonNetwork.LoadLevel(gameArenaSceneIndex); } }
0