Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Networking Lobby Example Beta Q&A

Discussion in 'Community Learning & Teaching' started by UnityGuillaume, Jul 17, 2015.

  1. Vedal987

    Vedal987

    Joined:
    Mar 10, 2015
    Posts:
    3
    Thanks I fixed it now I had to disable the movement scripts and camera for the other players!
     
  2. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    No, sorry, I was mistaken. Please disregard everything I wrote above. This is actually a bug: https://issuetracker.unity3d.com/is...ith-networkidentity-ignores-dontdestroyonload

    The weird thing is, though, the object isn't really destroyed, it just doesn't appear in the hierarchy. I'm adding a comment to the issue. (It has nothing to do with the lobby project really, but I am debugging why there is no server connection on my pure client instances and this appeared to be related.)
     
  3. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Look, I do not want to sound rude in any way, but to me some recent posts in this thread seem to be more of a discussion of general UNET issues and not too much related to the actual network lobby example. The lobby seems to be an important asset and example though, so I guess it would be nice to keep the focus and push quality progress of the actual network lobby example, so that it might move out of beta soon.

    UnityGuillaume, you seem to be active, did you already found some time to look into the issue I've pointed, concering minimum player count 1 with the network lobby?
     
    Last edited: Dec 7, 2015
  4. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    @moco2k, I understand your point. I try not to spam the world with every issue I encounter. Please bear in mind, however, it's not always clear what is a lobby issue and what is a Unet issue. Clearly I was mistaken about this, but still have no idea why my client can't spawn objects, etc. I would think anyone using the lobby would be having this same problem, so it's of interest.
     
    moco2k likes this.
  5. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    123
    Well lobby are pre-game gathering thing. Most game having a lobby don't support "hot join" in middle of the game. And sadly the LobbyManager that asset is based on don't support it either.

    It's possible with Unity Networking to create hot join scenario (it's just a matter of connecting to a server) but the lobby "forbid" that. Once the game is started, it's locked down by design.

    I'll try to ask the Networking team if there is an "easy" way to modify that (my guess is by using directly NetworkClient.Connect)
     
    moco2k likes this.
  6. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    Thanks for your answer. Yepp, I understand the design choice here. However, there are games that could use both a lobby and hot join option. For example, I think Left 4 Dead supports this as well.

    That would be awesome of course.
     
    Last edited: Mar 30, 2016
  7. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    Thanks for this asset, it's really interesting to pick apart and see how things work.

    One problem I was having though was with the player count, as the pong demo is only two players, the system seems to be set up with BYTE instead of INT, which throws errors all over the place when modifying this asset to work with anything other than a two player game.

    Really appreciate having this asset to play around with, and humbly suggest that the next version is a bit more flexible towards different game types. (games with more than two players) or a lobby tutorial makes it's way in to the documentation.
     
  8. BmDeveloperz

    BmDeveloperz

    Joined:
    Jul 1, 2013
    Posts:
    62
    Using unity's matchmaker causes timeouts because of huge package send rates. Even im using the standard network.transform with full compressed version i still get timeouts after 10 mins or something.

    Is this because i dont have unity pro ? is there something that free users are getting timeouts after a certain time or is it a bug ?

    Uncompressed transformation data's are sending 24 bytes/package and compressed are sending 19 bytes which is quite huge i guess.

    I would be grateful if anyone can enlighten me about the timeouts.
     
  9. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    Hi @UnityGuillaume I just downloaded the most recent version of Network Game Lobby (beta) (1.2) and it seems to have a lot of un-assigned errors in it's vanilla state in Unity 5.3, too many to go through and fix / understand.

    I tried in 5.2 and things run fine.

    spaceship game is a welcome addition; FYI score, lives and bullets don't seem to work.
     
    Last edited: Dec 10, 2015
  10. Gameccino

    Gameccino

    Joined:
    Aug 1, 2012
    Posts:
    40
    Hi @UnityGuillaume , great example.

    Doing some test I was just wondering how to use my own matchmaking server.
    There are not much, well pretty nothing, instructions how to use another matchmaking server.

    I found in the LobbyManager gameobject a configuration that points to mm.unet.unity3d.com but nothing else. Would be great to know how to configure my own matchmaking server.
     
  11. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    Hi @UnityGuillaume

    I updated to Unity 5.3 and every time the main game scene is finished, I get 2 LobbyManager in Lobby scene. I run it with Unity 5.2, I get the following warning: "Multiple NetworkManagers detected in the scene. Only one NetworkManager can exist at a time. The duplicate NetworkManager will not be used."

    Is there something I need to set on Unity 5.3? Or this is a bug on Unity 5.3?
     
  12. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    123
    This warning is now a "developer" log level warning in the Lobby. So if the log level is set to higher than that (the default "info" is) you won't see it. The warning was harmless and normal (hence why it was moved out of "normal" logging).

    The double lobby though, is a bug indeed. The lobby is "don't destroy on load", so when you go back to lobby, you have the previous "don't destroy on load" one and the one contained in the lobby scene.
    I've repro it, and warned the networking team, they should fix that in next patch release hopefully.

    As a temporary quickfix you can add :

    Code (CSharp):
    1.    void Awake()
    2.         {
    3.             if (FindObjectsOfType<LobbyManager>().Length > 1)
    4.                 Destroy(gameObject);
    5.         }
    in LobbyManager class in LobbyManager.cs
    This will destroy the lobby contain in the scene if you already have one around!

    Thanks a lot for catching that.
     
  13. BmDeveloperz

    BmDeveloperz

    Joined:
    Jul 1, 2013
    Posts:
    62
    Hello, i want to make the lobby rooms password protected. So when players wants to join, i want them to ttype the password to join the room. Does the lobby script support that kind of feature ? If not, i would be grateful if anyone can tell me that how i can save the password value to the certain lobbies.

    @UnityGuillaume And also if there would be some kind of lobby chat feature, that would be awesome. There is no examples about Chat system with Unet.

    Many thanks,
     
  14. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,151
    Can this example project handle just 1 room? is it still only way to run multiple exe on different ports to have multiple rooms?
     
  15. Eiseno

    Eiseno

    Joined:
    Nov 1, 2015
    Posts:
    86
    @UnityGuillaume

    Hi,
    I want make each client can select their player prefab in lobby and when game start i want instantiate selected prefab for client.I define varible in LobbyManager but its not working.Its always same with host.How can i make this ?

    Code (CSharp):
    1. public override GameObject OnLobbyServerCreateGamePlayer(NetworkConnection conn, short playerControllerId)
    2. {
    3. Debug.LogError(playerPrefabIndex + "Ins Index");
    4. GameObject playerPrefab = (GameObject)Instantiate(spawnPrefabs[playerPrefabIndex]);
    5. NetworkServer.Spawn(playerPrefab);
    6. return playerPrefab;
    7. }
     
  16. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    123
    If you use the matchmaker, room can be password protected (not in this lobby though), but see :

    OnClickCreateMatchmakingGame
    in LobbyMainMenu.cs you will see that an empty string is given to CreateMatch : this is the password.
    You could add an input field next to the room name in the menu for the password. But then you also need some way of asking for the password in the server lists.
    But it is indeed an important feature, I'll add it to the todo feature list, thanks!

    direct connection does not support password out of the box though.

    Not sure I understand : you mean creating 2 matchmaker game on the same computer? Seem to work for me, without playing around with port : launch the exe twice, create game on both with different name, can see the 2 games from a third instance of the game. Can you elaborate on what you are attempting? Thanks!


    It could be a couple of thing :

    How do you change playerPrefabIndex? if its a SyncVar, and you change it on client, it won't be replicated on the server (SyncVar do server-> clients sync, not the other way around). It should be changed through a Command, from the lobbyPlayer. But then you need an array of "playerPrefabIndex" and change only the right one throguht the Command.

    What I would suggest is to make the spawning of the right prefab the same way color is handled in the sample scene :
    - Make you gamePrefab an empty gameobject with the "setup/player/whatever" script on it, that have a "playerIndexPrefab" variable that is syncVar (just like the color is in NetworkSpaceship.cs)
    - Add a prefab index to the LobbyPlayer (see the Color var)
    - pass it to you player/setup script in the LobbyHook just like we do the color (see OnLobbyServerSceneLoadedForPlayer in NetworkLobbyHook.cs in the sample scene)
    - in the Start Function of your player/setup script, instantiate the right prefab and set it as child of your gamePrefabObject

    That way you don't touch the prefab selection and can handle everything from the lobby player, the right models/scripts/etc will be instantiated on each client when thing start.
     
  17. jerrywyj

    jerrywyj

    Joined:
    Jan 13, 2016
    Posts:
    1
    There is a bug in function OnClickCreateMatchmakingGame(), before fix it you can't on click BackButton after on click CreateButton. Add lobbyManager.backDelegate = lobbyManager.StopClientClbk; like below can fix it.
    Code (CSharp):
    1. public void OnClickCreateMatchmakingGame()
    2. {
    3.     lobbyManager.StartMatchMaker();
    4.     lobbyManager.matchMaker.CreateMatch(
    5.     matchNameInput.text,
    6.     (uint)lobbyManager.maxPlayers,
    7.     true,
    8.     "",
    9.     lobbyManager.OnMatchCreate);
    10.  
    11.     lobbyManager.backDelegate = lobbyManager.StopHost;
    12.     lobbyManager.isMatchmaking = true;
    13.     lobbyManager.backDelegate = lobbyManager.StopClientClbk;
    14.     lobbyManager.DisplayIsConnecting();
    15.  
    16.     lobbyManager.SetServerInfo("Matchmaker Host", lobbyManager.matchHost);
    17. }
     
  18. ErebusWolf

    ErebusWolf

    Joined:
    Mar 18, 2015
    Posts:
    3
    It looks like a new version just came out. Can we get a change log? I have a project that was using it and I'm going to run a diff to see what code changed but having something from you guys would be nice to bring to my attention any big things I should look at for moving forward for compatibility.
     
    Deleted User likes this.
  19. Deleted User

    Deleted User

    Guest

    @UnityGuillaume Is there a way to do this without making the desired prefab a child of the dummy prefab from NetworkLobbyManager? Doing so causes issues with Animation Events, which require the function to not be on a child object.

    I also looked into copying the components from the desired prefab onto the dummy prefab in OnLobbyServerSceneLoadedForPlayer(), but the ways that can be done feel too much like a hack that could break one day without warning when something in Unity changes under the hood.
     
  20. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    123
    Hum can't reproduced here, you shouldn't need the "stopClient" callback, there is already a stophost clalback (as when you create a matchmaking game, you are hosting it).
    Maybe something was fixed between your version and the one I have here (should be in 5.4 Standard Assets).


    It's mainly just upgrading to 5.3, and a couple of very slight bugfixes. If I happen to break API interface at any point, it will be stated in the changelog for sure! If you catch problems, don't hesistate to report them (either using Unity Bug Report from Help menu, or here. Bug report ensure I'll have it store somewhere to look at when my schedule allow!)


    Hum I was just suggesting that as a way of ordering your hierarchy, but having it not a child should work too. Just think of cleaning whatever you spawn in the OnDestroy function of your dummy (that way when the playerdisconnect, it's associated gameobject will be too on both client & server, and you will clean up everywhere all the associated gameobject). This could aslo be the place to for example give control of those "orphaned" objects to an AI (on the server) if you want the player count to stay the same etc..
     
  21. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    Hi, I'm struggling to get my account system integrated with the lobby. My game has a method it calls to load certain account information from a database. This is used to configure the player, etc. The information needs to be available on the server and the host. I've tried calling it on the server using a command, but one problem is that I don't have an object with authority around at the time I'm trying to call it. I've tried overriding certain methods in the lobby to trigger this command at the correct time, but haven't found the right spot to stick it. For instance, OnClientConnect is too soon. Neither the game or lobby player are created at that point. Otherwise it would be a great time for me to load the account info. I also tried OnLobbyServerCreateLobbyPlayer, which seems to run at about the right time, but then realized that only runs on the server, so it has no awareness of the correct account to load. I need something that runs on the client at the time a client decides to join a game in some way, but AFTER an object with command authority is created. This will allow me to pass my user token to the server and ask it to load the account info associated before it is needed to configure the game client scene. What is the right method to override, or am I using the wrong pattern? Thanks!
     
  22. Deleted User

    Deleted User

    Guest

    Thanks for replying back. In OnLobbyServerSceneLoadedForPlayer(), if I assign a different object to the gamePlayer that's passed in, it doesn't actually change that gamePlayer. Should it? For example, the following just instantiates another gamePlayer in the scene after the lobby and still spawns the same gamePlayer that's passed to the function.
    Code (CSharp):
    1. public GameObject gamePlayerPrefab;
    2.  
    3. public override void OnLobbyServerSceneLoadedForPlayer (UnityEngine.Networking.NetworkManager manager,
    4.             GameObject lobbyPlayer, GameObject gamePlayer) {
    5.  
    6.     gamePlayer = GameObject.Instantiate (gamePlayerPrefab);
    7.  
    8. }
     
  23. UnityGuillaume

    UnityGuillaume

    Unity Technologies

    Joined:
    Mar 16, 2015
    Posts:
    123
    Ok, keeping in mind that my knowledge of networking is close to zero, I think that the way to go here is to drop down to a level a bit lower in the API.

    You can see in "OnClickJoin" in LobbyMainMenu.cs that StartClient() is used to created the client & connect to server. What you want to do probably is use "UseExternalClient" (http://docs.unity3d.com/ScriptReference/Networking.NetworkManager.UseExternalClient.html).

    So I would do something like : Create a NetworkClient by hand, the doc should help. Then use that client to send a message to server (http://docs.unity3d.com/Manual/UNetMessages.html) that will be able to answer if needed. When the server answer/acknowledgement is received by the client, use "UseExternalClient" to "go back" to the normal NetworkManager behaviour & use the lobby again just like if you would have use StartClient (that create that NetworkClient for you).

    Sorry to not be more specific, my Networking knowledge is spotty. If there is major points of blocking, ask and I'll poke around when I have some more time.


    Just like any other C# code, gamePlayer is here only a "reference" to the object. By doing that you make it point to your newly created gameobject, but the other one is still somewhere (and probably reference by some system internal to UNET hence stoping it from being Garbage Collected).

    Also "OnLobbyServerSceneLoadedForPlayer" is ONLY called on the server. So here you would instantiate an object on the server but that object wouldn't be instantiated on the client (you would have to register it with the NetworkManager & use Network.Instantiate instead.)

    You have 2 choice here :

    Either you have a script on the "normal" gamePlayer, and in the Start function of this one you instatiate your prefab (NOT putting it as a child object, just storing a reference to it in your gamePlayer).

    Or you override "OnLobbyServerCreateGamePlayer" (http://docs.unity3d.com/ScriptRefer...bbyManager.OnLobbyServerCreateGamePlayer.html) in the lobby. You have to modify the lobby script for that (LobbyManager.cs)

    Whatever object that function return will be used as the gameplayer. But if you need info from the lobby to choose which gameobject to create, you'll have to store a connection/playerID to lobbyPlayer dictionnary somewhere, as that fonction only give you the NetworkConnection and playerID...

    NOTE /!\ : playerID isn't the position in the Lobby!! it's the LOCAL player numbers. So if you only have 1 player per client, it will always be 0.
    But if you have 2 players on a single machine (i.e. 2 player on one pc connected to 2 players on another PC) then you will have that fonction called twice with the same NetworkConnection but once with playerID 0 and another with playerID 1
     
  24. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    I never would have figured that out, thank you!

    I tried all the exposed (OnLobbyClient*) methods, and none of them happen fire at a "magic" time when I could find an active client. I've been trying to delay this til later and later, when the player objects are created, have the server send a ClientRpc telling the the client to respond with a command that carries it's ID. Wasn't working so far, and was a big mess anyway. Thank you again, I'm excited to try this!
     
  25. angusmf

    angusmf

    Joined:
    Jan 19, 2015
    Posts:
    261
    Ok, it doesn't quite work because the join button I'm clicking is actually on the lobby player. OnClickJoin is never called. But I can create my own lobby player that has a new command for this. It would be nice if the one in the asset had an overridable function for this. Thanks again!
     
  26. Cafn

    Cafn

    Joined:
    Jan 8, 2015
    Posts:
    19
    How/where is the name/color that the players write in the lobby manager is imported to the
    spaceship prefabs ingame? Can't find it out :(

    EDIT: Was able to find out and the color is well synced. Though the name doesn't get synced. Any idea why? (Even in the example it doesn't work)

    Edit nr2: On NetworkLobbyHook, change to the following:
    spaceship.playerName = lobby.playerName;

    Thanks for the great example!
     
    Last edited: Feb 10, 2016
  27. rossadamsm

    rossadamsm

    Joined:
    Feb 7, 2016
    Posts:
    7
    Once the match has begun I notice that all the players become clients (isServer=false). Is it possible to keep or set the player that hosted the game to begin with as the "server" so you can send further updates to the client using [ClientRPC] methods?
     
  28. LovesSolvingProblems

    LovesSolvingProblems

    Joined:
    Jan 22, 2015
    Posts:
    17
    Thank you for this great example! It took almost no time to get 2 instances up, running, and talking to each other. The code is very well written, and it's been an opportunity to learn about a lot more than just the lobby.

    In any case, I was trying to rebuild it from scratch and it seems to be going well, but when I try to drag a scene to the lobby scene or play scene on the lobbymanager script, it looks like it will take it but it leaves the value at none. Any advice what I might be doing wrong would be greatly appreciated.

    Thanks again!
     
  29. Deleted User

    Deleted User

    Guest

    Be sure to add the scenes to the build settings first.
     
    LovesSolvingProblems likes this.
  30. LovesSolvingProblems

    LovesSolvingProblems

    Joined:
    Jan 22, 2015
    Posts:
    17
    Thank you Rikey, that was exactly it! Much appreciated
     
  31. Nicolas-Liatti

    Nicolas-Liatti

    Joined:
    Jun 19, 2013
    Posts:
    89
    Hi,

    I have a problem with OnStartLocalPlayer() when using the LobbyManager.
    The game scene loads fine, but when I am using GameObject.Find("xxx") in OnStartLocalPlayer() it does not find any object in the scene, even if they are here (Object Reference not set to an instance of an object).
    If I use the Component NetworkManager instead of LobbyManager it works fine...

    How should I do to find some Gameobject as soon as the players join the scene if the GameObject.Find in OnStartLocalPlayer can't find them..?

    Thanks,
     
  32. SpaceMidget75

    SpaceMidget75

    Joined:
    Feb 7, 2014
    Posts:
    21
    There appears to be a bug and logic problem with the disconnection code using this Asset clean, with no changes.

    As discussed above, this system is designed to NOT allow people to hot join. They have to be in the lobby before starting which is fine for me personally.

    I've set the demo project to 2 max players and 2 min players. Start a game and then have the CLIENT quit. If you do this two things happen 1) The host remains in the game despite it being less than the min players 2) the client goes back to the lobby with a "Join" button which when clicked tries to reconnect you, but doesn't.

    I would expect that you either quit the host from the game when it drops past the minimum players (recommended) or allow the client to re-join.
     
  33. Deleted User

    Deleted User

    Guest

    @UnityGuillaume Thanks for all the hard work so far. Any chance this will come out of beta and be something easier to integrate into an existing project, like include the "Network" folder and pull a LobbyManager prefab into a scene?
     
    LovesSolvingProblems likes this.
  34. LovesSolvingProblems

    LovesSolvingProblems

    Joined:
    Jan 22, 2015
    Posts:
    17
    Not sure if this will do the trick or not, but I have a find method I use for finding gameobjects that aren't enabled. Here's a couple examples of the usage. Below that is the class, just create a c# class called Util and overwrite it with this. Maybe you will get lucky :)
    Code (CSharp):
    1.     private GameObject  banner;
    2.     private Text        header;
    3.  
    4.         banner = Util.Find(gameObject, "Banner");                      
    5.         header = Util.Find(gameObject, "Header").GetComponent<Text>();
    6.  
    7.  
    8. /// <summary>
    9. /// My trusty utility class
    10. /// </summary>
    11. public class Util {    
    12.  
    13.     public static GameObject Find(GameObject parent, string name)    //find using Gameobjects
    14.     {
    15.         return Find(parent.transform, name).gameObject;
    16.     }
    17.  
    18.     public static Transform Find(Transform parent, string name)     //find using Transforms
    19.     {
    20.         if (parent.name.Equals(name)) return parent;
    21.         foreach (Transform child in parent)
    22.         {
    23.             Transform result = Find(child, name);
    24.             if (result != null) return result;
    25.         }
    26.         return null;
    27.     }
    28. }//===========================End of Class Util
    Good luck!!!
     
  35. moco2k

    moco2k

    Joined:
    Apr 29, 2015
    Posts:
    294
    @UnityGuillaume, are the any updates on this topic?
     
  36. Deleted User

    Deleted User

    Guest

    Last edited by a moderator: Mar 25, 2016
    kevinrodrigues likes this.
  37. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Uhm, can anybody guide me a little bit on passing data from the lobby player?
    I am trying to use the Colour-property as a team-selection sort of thing. Players should be able to switch to faction Red or faction Blue.

    Any idea? Thanks in advance.
     
  38. Deleted User

    Deleted User

    Guest

    Check out OnLobbyServerSceneLoadedForPlayer(). The lobby player and game player objects are both available there, so you can handle everything inside that function. When setting things on the game player, they should usually be SyncVars, because this function only runs on the server.
     
  39. Justice0Juic3

    Justice0Juic3

    Joined:
    Apr 29, 2013
    Posts:
    188
    Are the Unity Multiplayer services down at the moment? I can't seem to play my own game or test any other UNet projects. Yes, I linked my project.
     
    Last edited: Mar 27, 2016
  40. ben-maurin

    ben-maurin

    Joined:
    Apr 7, 2016
    Posts:
    47
    Hi.

    I'm a testing the lobby prefab and it kinda work but I have a very annoying problem :

    It only work the second time the host is launched. It's not possible to add player (it go in TryToAddPlayer(), but nothing happen, event with good max player per connection values). The only way to make it work is to stop the host and launch it again. The next times (until application is closed) the host is launched, it will correctly work.

    With debug level to develloper, the only log is this three lines when adding a player :

    The second time I launch the host (when it works) there is 19 debug lines.
    The first Time the host is launched the log stop just before where it was supposed to log
    Does anyone has the same problem or an idea ?


    ------------------------------------------------


    Edit :

    Ok the solution was simple. The scene in which you put the lobbyManager prefab, need to be the same as the "lobbyscene" you link. It's pretty annoying, so I created an Empty scene and set managers to dontdestroyOnLoad. It should be a way to bypass the needed gamescene and lobbyscene.
     
    Last edited: Apr 11, 2016
  41. geep_

    geep_

    Joined:
    Apr 18, 2016
    Posts:
    25
    UnityGuillaume -
    Here's a challenge for you, should you care to accept it. Create and distribute a version of your Unet Lobby beta/Asteroids that has a choice of 2 space ship prefabs, such as "fat" and "skinny" sprites. Add a toggle to the lobby player, a checkbox for "fat". Demonstrate that the correct spaceship is spawned under all circumstances, e.g., whether the requestor is a client on the host machine or not. Ideally, provide a solution that would work with prefabs that are animated. Spacecraft color should still work too.

    I've been trying to do something similar for days, using your suggestions and those in other forums. As my test case, I'm using 2 Thirdpartycontroller-with-Ethan prefabs. They are identical, except 1 has the eyeglasses disabled. So I have a "Glasses" checkbox in the lobby. The checkbox value is propagating properly across clients. But I haven't been able to find a consistently working player spawn method.

    If you could make that work, it would help not just me but I suspect lots of folks. Or if there's no way to make it work with the NetworkLobby, that would be good to know too. Thanks for considering.
    Geep_

    BTW, I've been only testing the direct join system, not the matchmaking. Lack of "hot join" capability in the latter is a discouragement for me too.
     
    Last edited: Apr 18, 2016
  42. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    geep - that's not a huge challenge. The lobby example shows you how to do that yourself. Take what they did for the color and just expand it to do multiple things.

    You don't need two prefabs, just use lists of animators/sprites and switch depending on lobby choices.
     
  43. Emr1sHD

    Emr1sHD

    Joined:
    Apr 19, 2016
    Posts:
    1
    Hey Guys,

    I am new to networking and tried this example but it's not working for me at all.
    It says i've got an invalid projectid setup. What's wrong? It says i have to go to multiplayer.unity3d.com and do stuff, but can't figure out what. I made an project with an UnetID but what's next?

    Thanks in advance.
     
  44. geep_

    geep_

    Joined:
    Apr 18, 2016
    Posts:
    25
    Thanks for the feedback, SkyTech6. I should have been clearer. The 2-Ethans is just a test case. I agree with you that if this particular choice of avatars was the end goal, I could easily do it with just a single prefab, and hide/show the eyeglasses. But it's not. I'd ultimately want to provide a choice among more elaborately-different characters (e.g., from Fuse/Mixamo or possibly UMA 2), and I'm pretty sure that would require separate prefabs. So I need to get player prefab selection to work.
     
  45. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    Well even separate prefabs isn't hard. I'd say it is even easier to do.

    Before I found this Lobby Example I made a multi-prefab spawning system for my UNet game using almost entirely no UNet coding. Simply made a Master Prefab that would check the player's script and spawn them their actual player prefab and give them control of it.
     
  46. geep_

    geep_

    Joined:
    Apr 18, 2016
    Posts:
    25
    I'd like to give that a try. Could you post some code (I guess from within Awake() or Start() of Master Prefab) or point me towards sample code? The spawn and pass-player-control aspects particularly. Do you need to make the real prefabs children of the Master Prefab, either in the hierarchy or on-the-fly? Thanks for your help in getting my head around this.
     
  47. SkyTech6

    SkyTech6

    Joined:
    Jul 14, 2015
    Posts:
    151
    I've actually converted over to a single prefab method that uses case switch machines to determine which sprites/animator/spawn position they need. It was long ago when I used the Master Prefab method.

    Even then though, I had a counter in my Game Master that assigned a number to the Master Prefab. Then the master prefab had a Start() that would launch a case switch machine which held the proper information of which prefab to spawn for which number and included authority controls in that.

    Like this to give authority,

    Code (CSharp):
    1. GameObject avatar = Instantiate(PlayerAvatar) as GameObject;
    2. NetworkServer.SpawnWithClientAuthority(avatar, gameObject);
     
  48. geep_

    geep_

    Joined:
    Apr 18, 2016
    Posts:
    25
    Thanks. Your single-prefab method sounded more flexible to me, so I'm trying that first. Going back to a single ThirdPersonController as gamePlayer, with now 2 avatars+models (just Ethan and Ethan 1 for testing), shared animation as before. With switch logic for the avatars+models inside the Start() of ThirdPersonUserControl. Some problem with SyncVars not getting passed, but I'll beat on it further.
     
  49. imgodot

    imgodot

    Joined:
    Nov 29, 2013
    Posts:
    212
    Wow! I was going to post a question here but it looks like the thread has been abandoned by Unity.
    (Sigh.)
     
  50. nghetienhiep

    nghetienhiep

    Joined:
    Apr 12, 2016
    Posts:
    2
    Now, in the store "Network packet Lobby" no scene. What can I do.