Syncing scenes, Pre-game Lobby - Instantiation issue

Options
So my game has a pre-game lobby scene before the actual game scene is loaded. The player has already chosen a game at this point, it is not a typical "lobby", it is where players can text/voice chat before the game, select their team, change loadouts, etc. Everything works great for all the players in the game at initial load time. The problems arise for the late joiners. The player prefabs which are created with PhotonNetwork.instantiate on the 2nd scene show up too early in the lobby (1st scene) and then are nowhere to be found once they enter the game. As a result, players already in the game can see them but not vice versa.

The only way I know of turning off the RPC calls and preventing the instantiation from happening is by setting "PhotonNetwork.isMessageQueueRunning" to false. Unfortunately, I need this to be set to true as I need an updated list of players playing shown in the pre-game lobby. Also I am using "PhotonNetwork.automaticallySyncScene" to join the game once the player is ready.

Flow: Game Creation/Game Search ---> Scene 1 (Pre-game lobby) ---> Scene 2 (Actual game)

I have been working on this about 6 hours trying to figure it out, super frustrated, hope someone can help!

Comments

  • Hmp, interesting. I think what might be happening is, since this is a "pre-game lobby" (AKA actually the game), the "late joiners" are getting the prefabs spawned of the "early joiners" as they should, but in the first scene instead of the second. So, as a result, when the late joiners finally join the game (and switch to scene 2), those prefabs are destroyed. Maybe specifying DontDestroyOnLoad(transform.gameObject); in the awake of the photon instantiated prefabs would do the trick? This is mostly conjecture, but it seems to make some sense.

    edit: setting PhotonNetwork.isMessageQueueRunning = false; may do the trick also, if you then set it back to true after you've switched to Scene 2?
  • I actually just had this same problem.

    By setting "PhotonNetwork.isMessageQueueRunning = false;" when joining the room..

    Then setting it BACK to true when the level is loaded will fix any issue.
  • Thanks for your help. Sure enough, that fixes the issue! However, once the late joiner enters the game, a bunch of other stuff breaks :( UGH! Things are out of sync, GUI elements aren't showing up, my room respawn property which is clearly set to false, somehow gets set to true. None of this makes sense. Back to the drawing board I guess.
  • Tobias
    Options
    You can also set PhotonNetwork.automaticallySyncScene = true in all clients (when you start) and then use PhotonNetwork.LoadLevel() to load the correct level.
    Let me know if that works for you or if you have a solution.