New client loads old scene when joining room

Options
Hey guys!

I'm making a game where I have a main menu scene where I can join games and etc and other scenes where the game happens, after a match finish the players go back to the room screen in this main menu scene so the players can rematch, leave the room, wait for other players to join the room and etc. My problem is that when a new player joins this room he loads the game scene instead of the main menu scene (where all the other players - that already played in this case - are). I'm trying to activate and deactivate automaticallySyncScene but sometimes that doesn't seems to work, do I need to set this in all clients in the room? Do I need to set this when the level loads? I'm loading the game using photon's LoadLevel, but still, new clients goes to the game scene.

When a match finish I want to be able to let players review the score before going back to the room screen in the main menu scene, he wil be able to go back to it through a button, and each player should be able do this by himself without the master client forcing him. I was able to nail this, but when new players joins this room (that just came back from a match) he loads the game scene automatically and I have no control over it.

Can I have more info about how automaticallySyncScene really works and how to use it?

Comments

  • Hi @Rodolfo_Rubens,

    as stated in the API, automaticallySyncScene stores an entry in the custom room properties when PhotonNetwork.LoadLevel(...) is called by the MasterClient. Basically the name or index of the loaded scene is stored. If a new client now joins the room and his current scene differs from the one stored in the properties, the client starts loading another scene. Feel free to read the entire API entry here.

    You can also take a look at the PhotonNetwork script (lines 3196 and 3222) or directly at the NetworkingPeer script (line 4454) to get a more detailed look onto that behaviour.
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Rodolfo_Rubens,

    I just wanted to add to @Christian_Simon's answer, that ICYMI we have this documented here.
  • Rodolfo_Rubens
    edited April 2017
    Options
    Hey guys!
    Thanks for the replies!

    automaticallySyncScene stores an entry in the custom room properties when PhotonNetwork.LoadLevel(...) is called by the MasterClient

    Ah, I think I skipped that part in the documentation, thanks!

    From the second link:
    Just set PhotonNetwork.automaticallySyncScene = true before you connect and use PhotonNetwork.LoadLevel() on the Master Client of a room

    That means automaticallySyncScene only works before I connect? I can't change it while already in a room? sometimes it seems like I can...

    What I needed is to be able to define the default room for new clients to load but I also needed to be able to let the master client only loads the MainMenu scene (which would at this time already be the default level) when he wants to (in case new clients joins but the master client didn't load the MainMenu scene yet, since the master client needs to load a level to set this level as the level to sync), kinda confusing, I was able to achieve this by setting some custom room properties but I'm afraid to hit some bugs ahead, for now is working.

    Last question, is automaticallySyncScene a variable that any client in the room can set it, or only the master client?

    Thanks a lot guys!

    edit: Ah, I forgot to mention that even after the master client has loaded the MainMenu scene, the new client loads the old scene (game scene) when he joins the room, which is why I was confused about the automaticallySyncScene and how it works.