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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Possible to carry Network to a new Scene?

Discussion in 'Multiplayer' started by JakeLeB, Jun 8, 2015.

  1. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    Hi, I've long used Photon for my Multiplayer Test Games but I've decided that I want to use Unity's inbuilt, it's pretty much similar so I haven't had much trouble but I've came to a halt it seems.

    The first Scene I have is the menu system, this handles the main menu, starting a server, connecting to a server. Which all works, you can see in the GameView using Stats that players are connecting, to test with I've bypassed the Room Menu where players will check when ready etc.

    So once a player is Joined they then load the Game Scene, a very basic map with only Spawn Points in. But it seems when I start the ServerClient I spawn in as I want, then if I load a second Game up and connect, I'm listed as in the game in the Stats but in-game it's as if neither players can see each other. I don't even get a second Player prefab in the ServerClients inspector.

    Am I restricted to only one Scene? Or is it possible to Spawn players on a Network after switching Scenes?
     
  2. Sehlor

    Sehlor

    Joined:
    Feb 10, 2012
    Posts:
    199
    DontDestroyOnLoad, check it out.
     
  3. Brent_Farris

    Brent_Farris

    Joined:
    Jul 13, 2012
    Posts:
    881
    DontDestroyOnLoad will not help in this matter. All of the buffered RPC calls and instantiates will happen when you connect to the server. You don't want a DontDestroyOnLoad on all of these objects.

    However, one solution would be to use LoadLevelAsync. You can place all the objects in the scene in a single object in the hierarchy and then disable it or destroy it if you no longer want them.

    http://docs.unity3d.com/ScriptReference/Application.LoadLevelAsync.html

    Another solution would be to use a different networking solution that allows you to control how you spawn and buffer objects like Forge. (Shameless plug after providing an answer for the current implementation XD)

    Let me know if you would like further help on this issue using the built in Unity Networking, I used it for quite some time before writing my own solution.
     
    JakeLeB likes this.
  4. JakeLeB

    JakeLeB

    Joined:
    Apr 18, 2013
    Posts:
    25
    Yeah DontDestroyOnLoad does not work,at the moment I'm away but ill look into those Farrisarts.