- Home /
UNET Multiplayer Lobby not creating an instance of the lobby player
I'm trying to create a multiplayer lobby with UNET. I have a game object in my lobby scene with the Network Lobby Manager component attached to it. The Lobby Player variable has a reference to a prefab with a Network Identity and Lobby Player component. I'm wanting to build the GUI from scratch rather than using the Network Manager HUD so I have some buttons such as "Start Host" and "Start Client".
Clicking the "Start Host" button calls "StartHost()" and I get debug telling me that the host has been started and that a server and a client has connected. However I was under the impression after reading through the documentation, that when a client connected (I've tried this locally and not) that the lobby manager instantiates a lobby player automatically for every connected client. Mine doesn't do this.
Setting the log level of the Network Lobby Manager to Debug instead of Info, I get some extra debug that says "Ready with no player object" but I don't know whether that is in relation to something failing and not being able to instantiate a Lobby Player?
Has anyone had a similar situation? Or know of any tutorials or documentation on creating a UNET lobby? I have read all the documentation in the manual (which I find very shallow) and I've also downloaded the Network Lobby and Network Starter sample projects. I can't see any other code they call in order to work and my manager setups are the same. Am I missing a certain call??
Thank you!
I found this quite usefull, when I started working on lobby: http://forum.unity3d.com/threads/networking-lobby-example-beta-q-a.341592/
(In case you didn't find this example yet) (And yes, the documentation currently is a pain to work with...)
Thanks, I have been using that sample. Just trying to step through it bit by bit right now, and it still won't instantiate a Lobby Player in my scene. I can't see if there's any code being called in the project that I'm not calling. So either I am missing a call or my settings aren't set up correctly?!
I've had that problem when I was instantiating my Lobby$$anonymous$$anager via script ins$$anonymous$$d of putting it in a scene and loading that scene. $$anonymous$$aybe this is your problem as well?
I have a similar issue, only that the LobbyPlayer isn't created until I exit and re-open the scene again, sometimes. It's very frustrating.
Answer by glitchers · Jun 17, 2016 at 04:36 PM
I had this issue even with Auto Create Player set to true.
It was because OnServerAddPlayer
was exiting the function early because the loaded scene wasn't the scene it expected as the 'lobby' scene. If you look at this function in the source (the HLAPI is all on bitbucket, I highly recommend downloading it) you can see the first thing it checks is if the current scene is the lobby scene it expects.
I had inconsistent behaviour with this as sometimes the scene would load in the editor fine and a lobby player would be created but most of the time it wouldn't work. Additionally as this is the 'desired' behaviour nothing is logged.
For me this is because I was creating/joining a matchmaker game from one screen and loading the lobby scene in the same function. I now use a scene loading system I've made to determine when the scene is fully loaded before trying to start/join the match and the problem is gone.
Hope that helps anyone else who comes across this like I did.
Hey! I have the same issue, can you share a bit more what you did to solve the issue? For example how do you deter$$anonymous$$e if the scene was loaded and then try to join? I debugged it and it shows that indeed the scene is the lobby scene so I'm a bit at a loss on this. The weird thing is it plays normally when I connect it with a pc in my region but i get the problem when somebody from another area connects
Your answer
Follow this Question
Related Questions
Clients can't spawn bullets, but the server does 1 Answer
[UNET] LobbyManager - OnLobbyServerSceneLoadedForPlayer() not executing for clients 1 Answer
Loading spawned prefabs upon connecting to server? 1 Answer
Multiplayer game with multiple level 0 Answers
OnStart ___ vs OnLobbyStart ___ methods from NetworkManager and NetworkLobbyManager 1 Answer