Search Unity

[Solved] LobbyManager - cannot spawn players in further scenes

Discussion in 'Multiplayer' started by RR7, Mar 15, 2018.

  1. RR7

    RR7

    Joined:
    Jan 9, 2017
    Posts:
    254
    I'm trying to use the HLAPI to achieve the following, based off the network lobby tutorial package:

    * (working) players join lobby, mark themselves as ready, once ready, game starts and loads level 1.
    * (working) after level one, debrief scene is loaded via ServerChangeScene
    * (not working) after debrief, ServerChangeScene is used to load level 2 - where all players should spawn back in and start the level - at the moment the scene starts but the players never spawn in.

    it seems that after the LobbyManager starts the first scene, all players exit the lobby automatically by the HLAPI.

    this sounds so simple i cant help but think i'm missing something obvious in the documentation, purely because i don't know what i'm looking for.

    is there something like 'the way' you are supposed to do this?
     
  2. RR7

    RR7

    Joined:
    Jan 9, 2017
    Posts:
    254
    maybe I'm a bit closer to knowing what it is I don't know.

    so the lobbymanager has all lobbyplayers added, all set to ready, it starts, then changes to the playscene and players spawn in.

    when it changes scene from the play scene to my debrief screen, since its not going back to the lobby, all the lobbyplayers remain, they are still present, and still set to ready, so when I change to the next level scene, I don't know whats different that they don't spawn in this time. i'm looking at the source code but I cant seem to find the magic piece that says 'if this then spawn them in, otherwise don't bother'
     
  3. RR7

    RR7

    Joined:
    Jan 9, 2017
    Posts:
    254
    looks like the answer is to mark the spawned players as DDOL handle re-positioning when the next level loads.

    what I was trying to do re-spawn fresh each time, but it seems the HLAPI really doesn't want to do that!
     
  4. RR7

    RR7

    Joined:
    Jan 9, 2017
    Posts:
    254
    after looking further into this, it seems I didn't need to set DDOL. my problem wasn't that I needed the player to stay between scene changes, but that I needed the player be destroyed, but to respawn after the scene change, into the next one.

    my issue was that I was using the lobby tutorial as my base, I was able to do a few things so make the players respawn into a scene after the initial one.

    setting the lobbyscene and playscene to different values after going into the playscene.
    override the OnClientExitLobby so the player doesn't get removed - the menu system kills like lobby when exiting out, it needs work but this is the approach
    the lobby player object needs to be active and also not the child of an inactive object. then when the scene changes again, as long as the lobbyscene is the current scene and the scene that loads is currently set as the playscene, it will spawn the players again.