Search Unity

LobbyPlayer to GamePlayer NetworkLobbyManager

Discussion in 'Connected Games' started by Ahkilleux, Aug 23, 2015.

  1. Ahkilleux

    Ahkilleux

    Joined:
    Mar 8, 2014
    Posts:
    2
    I hope this helps someone.

    OnLobbyServerSceneLoadedForPlayer not getting called?

    OnLobbyServerCreateGamePlayer not getting called?


    public override bool OnLobbyServerSceneLoadedForPlayer(GameObject lobbyPlayer, GameObject gamePlayer)

    ..and..

    public override GameObject OnLobbyServerCreateGamePlayer (NetworkConnection conn, short playerControllerId)

    ..do absolutely nothing for you if your lobby player object is set to be destroyed on scene load. NetworkLobbyManager is set this way by default. I made the assumption that it held an internal reference to any networklobbyplayer instances it spawned. That assumption cost me hours of digging through forums and documentation and trial and error trying to find out why my gameplayer object was never being created when the main game scene loaded.


    Make sure to add one of these

    void Awake() {
    DontDestroyOnLoad(transform.gameObject);
    }

    to your NetworkLobbyPlayer subclass.

    And if anyone from Unity is listening in. Maybe an extra bullet point here http://docs.unity3d.com/Manual/UNetLobby.html ?
     
  2. onecrazysim

    onecrazysim

    Joined:
    Jun 22, 2014
    Posts:
    2
    It helped me, thanks, same scenario happened in 5.3.1fp2
     
  3. thomak-dev

    thomak-dev

    Joined:
    Mar 8, 2015
    Posts:
    15
    My LobbyPlayer had a Start method defined. Thanks to this thread and the UNET source code I then found out that my Start method hid the NetworkLobbyPlayer Start method where Unity does the DontDestroyOnLoad.

    Maybe Unity should make the Start method virtual so we can actually see that we are hiding something? Or removing all magic methods altogether?
     
    rikey likes this.
  4. Wurghi

    Wurghi

    Joined:
    Apr 11, 2013
    Posts:
    39
    damn, thank you very much, i had his problem for months now and i was close to stepping back from unet
     
  5. Jtoomer

    Jtoomer

    Joined:
    Jan 30, 2017
    Posts:
    38
    I wasted almost 8 hours due to not knowing this. Multiplayer networking is hard enough without having a missing piece of the puzzle like this.
     
    mcbauer likes this.
  6. dinoelzik

    dinoelzik

    Joined:
    Jan 29, 2015
    Posts:
    1
    Thanks dude, it helped me a lot.
    I've spent so much time for debugging before found this post.
     
  7. greeneninjagames

    greeneninjagames

    Joined:
    Mar 23, 2017
    Posts:
    4
    Adding +1 to the suggestion that Start() should be virtual so we know we're covering up needed logic.
     
  8. EddyDavila

    EddyDavila

    Joined:
    Mar 13, 2017
    Posts:
    2
    Make sure to add one of these

    void Awake() {
    DontDestroyOnLoad(transform.gameObject);
    }

    to your NetworkLobbyPlayer subclass.

    And if anyone from Unity is listening in. Maybe an extra bullet point here http://docs.unity3d.com/Manual/UNetLobby.html ?[/QUOTE]
    THANK YOU!
     
unityunity