Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Third Party Photon Networking and scenes

Discussion in 'Multiplayer' started by jessee03, Feb 2, 2015.

  1. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    I was wondering if anyone had any examples of having clients switch between different scenes while on the same server. Such as each scene being different level / world. Allowing players to switch between different scenes and join other players in those scenes. So it wouldnt be creating multiple instances of the scenes but just allowing players to switch from one scene to another.
     
    wlwl2 likes this.
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,018
    You decide to load another scene and all players in a room should do the same?

    To sync the loaded level in a room, set PhotonNetwork.automaticallySyncScene to true (e.g. where you connect).
    Then use PhotonNetwork.LoadLevel(string levelName) on the Master Client to trigger loading another scene.
    Keep in mind that this usually destroys all objects due to loading a new scene (just like Unity usually does). You can disable this via PhotonNetwork.autoCleanUpPlayerObjects.
     
  3. jessee03

    jessee03

    Joined:
    Apr 27, 2011
    Posts:
    729
    Oh it would just be for the player that wants to switch scenes, so not everyone. So one player could be in a forest scene while other users are in a mountain scene. Then allow players to switch between the different scenes to join other players in those scenes.
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,018
    I think I don't really understand the scenario.
    In doubt: Create a room per scene and when players need/want to switch the scene, your code also switches to the fitting room.