Networking Lobby Example Beta Q&A

We have released a beta version of the Networking Lobby Example on the Asset store .

This pack contains a multiplayer lobby using either the Networking matchmaker service (https://multiplayer.unity3d.com) or a manual connection by IP address.

NOTE : This is a beta! Some bugs may be expected. You can help make it better by please reporting any problem you have with this package using the in-editor bug reporter!

USAGE

Instructions are included in Standard Assets/Network/Instruction.txt

  • You will need two scenes : one for the lobby, one for the game
  • These scenes need to be added to the Build Settings window. (File > Build Settings)
  • Drop the LobbyManager Prefab into your scene
  • In the LobbyManager script component, drop your scenes into the fields “Lobby Scene” and “Game Scene”.
  • Drop your game player prefab into “Game Player Prefab” slot. This prefab will need to have a script deriving from NetworkBehaviouron it. (See Spaceship in SamplesScene/Prefabs for an example of a Game Player Prefab)
  • Set “Min Player” to the minimum number of players needed to start a game (0 = no minimum)

Additionally, if you want to pass data from the lobby player (the sample one has a name and a colour) , you can derive a script from LobbyHook (see SampleScenes/Scripts/NetworkLobbyHook for an example) and add it to your own LobbyManager

Please note that the prefab will output information / warnings in the Console. This is normal! To control the amount of logging output by the Lobby, in the LobbyManager script inspector change the Log Level parameter.

Lobby screen

You can add a local player with the Add Local Player “+” icon.
The Remove Icon will be grayed out for other clients players (apart if you are the server) or if you are the only local player (you can’t remove all your players!)

Game Lobby Example

You can create a lobby:

  • Through the Matchmaker by clicking Create after entering a name
  • For Direct Connection by clicking Play and Host.

Both will create a local server on your machine and connect you to it.

Other players can then join by doing

  • “List Servers” (if the match was created with Matchmaker)
  • By entering your IP address (if you created with Play and Host)

NOTE : Direct IP can fail if you are behind NAT, firewall etc… It is recommended to use the matchmaker for non LAN game!

Matchmaker

To be able to use the matchmaker, you need to create a project in the Unity Services tab (Window > Unity Services and select Multiplayer in the list)

Sample Asteroid

The directory SampleScenes/Scenes contains two samples scenes for a simple networked game of Asteroid. It’s a simple example here to show how to interact between a lobby and a game.

Open the lobby scene to see how a lobby is set.

The script SampleScenes/Scripts/NetworkLobbyHook.cs will show you how to pass info from the LobbyPlayer to the GamePlayer.

2 Likes

My computer starts to overheat when running the sample lobby scene in the editor or as a standalone on Mac. My Mac is less than 2 years old, but I don’t have a dedicated graphics card. Could this be why, due to the sample lobby using a taxing UI?

It’s more likely you have a problem with the cooling system in your PC, blocked heat sink or failed fan possibly.

Nope, nothing wrong with this MacBook Pro.

Have you run the profiler of this?

We’re not seeing anything wrong as far as we can tell…

If you can find a glitch, we’d love to know about it.

Hi Adam,

Thanks for your response. I just ran it with the profiler, and I’m not sure what to look for, but nothing jumped out at me. As far as the laptop getting hot, I’m 99% sure it’s because I don’t have discrete graphics.

Do you find this to be true with other Unity scenes? Or just the lobby?

If you want, you can file a bug report from you in-editor reporting tool, and it will include a snapshot of your hardware.

This is the first time I’ve seen the laptop heat up with a project running in the editor; it’s a project with just the assets from the package. A game like Portal will heat up my laptop, so that’s why I think it’s a weak graphics hardware thing.

I’ll go ahead and do that in case it is of any help.

Thanks. Can you get the report number to me, just in case?

Hi! I did all that is described in instruction 1-6, but it is working only on local machine. When I try to connect with other users over the web it is not working. What else should I do to make it working?

Direct IP connections may fail for lots of reasons (firewall, NAT, routers etc…) (

That’s why the matchmaker is here, a server at Unity will connect two computer, taking care of all that.
To use the matchmaker, as stated, you need a cloud project id, and to get this, you have to register your project at https://multiplayer.unity3d.com

(nice side effect, setting a project ID will also connect your project to all the Unity service, such as Analytics, cloud build, database, Ads etc. )

1 Like

Hello, I have registered my project on https://multiplayer.unity3d.com and use matchmaker as stated in the instruction. But it is not working. Is there any detailed instruction on how to use matchmaker? Maybe I am doing something wrong… I just registered my project and entered project ID.

Hum it should be the only thing to do : enter the cloud ID that https://multiplayer.unity3d.com five you in the “Cloud Project Id” field in “Edit > Project Settings > Player”

On one player :
Enter a name in “Create a Game” section of the matchmaker, and click “create”.
Other players:
Find it by clicking “List server”

What does not work? Crash? error? Can find the game from a client?

What is your version of Unity?

Try to create the game in the editor and see if there is warning/error (yellow or red text) in the console.
Then create the game on a standalone build, and try to List Servers in the editor and check also for error/warning in the console.

After creating a match, but before starting it, if I go back to the main panel and call StopMatchMaker, StopServer, and StopClient, OnStartLocalPlayer on the lobby player object is automatically called between the calls to StopServer and StopClient. Is this a bug?

I use Unity 5.1.1f1. I created new project. Created Cloud id - fe107d36-15a7-4481-8cff-6950ebc1f5fe and entered it in Player settings.
When I hit play, give a game name “A3” and hit Create into “Create Game” section I have got following errors:
Failed to read the ID for the match maker, please set the Cloud Project ID string in the Player Settings (see https://unet.cloud.unity3d.com).
UnityEngine.Networking.NetworkManager:StartMatchMaker()
UnityStandardAssets.Network.LobbyMainMenu:OnClickCreateMatchmakingGame() (at Assets/Standard Assets/Network/Scripts/Lobby/LobbyMainMenu.cs:59)
UnityEngine.EventSystems.EventSystem:Update()
MatchMakingClient Create :https://mm.unet.unity3d.com/json/reply/CreateMatchRequest
UnityEngine.Networking.Match.NetworkMatch:CreateMatch(String, UInt32, Boolean, String, ResponseDelegate1) UnityStandardAssets.Network.LobbyMainMenu:OnClickCreateMatchmakingGame() (at Assets/Standard Assets/Network/Scripts/Lobby/LobbyMainMenu.cs:60) UnityEngine.EventSystems.EventSystem:Update() System.FormatException: FAILURE Returned from server: Failed CreateMatch for appId=Invalid at UnityEngine.Networking.Match.Response.Parse (System.Object obj) [0x00000] in <filename unknown>:0 at UnityEngine.Networking.Match.CreateMatchResponse.Parse (System.Object obj) [0x00000] in <filename unknown>:0 at UnityEngine.Networking.Match.NetworkMatch+<ProcessMatchResponse>c__Iterator01[UnityEngine.Networking.Match.CreateMatchResponse].MoveNext () [0x00000] in :0
UnityEngine.Networking.Match.c__Iterator01:MoveNext() JSON Response: [[UnityEngine.Networking.Match.CreateMatchResponse]-success:False-extendedInfo:Failed CreateMatch for appId=Invalid]-address:,port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False UnityEngine.Networking.Match.<ProcessMatchResponse>c__Iterator01:MoveNext()
Create Failed:[[UnityEngine.Networking.Match.CreateMatchResponse]-success:False-extendedInfo:Failed CreateMatch for appId=Invalid]-address:,port:0,networkId:0x0000000000000000,nodeId:0x0000,usingRelay:False
UnityEngine.Networking.NetworkManager:OnMatchCreate(CreateMatchResponse)
UnityStandardAssets.Network.LobbyManager:OnMatchCreate(CreateMatchResponse) (at Assets/Standard Assets/Network/Scripts/Lobby/LobbyManager.cs:227)
UnityEngine.Networking.Match.c__Iterator0`1:MoveNext()

If I am on the project page Unity ID and refresh page, I got following error: Unable to load project. (400).

Upgraded to 5.1.2p3 and installed a fresh copy of this package. When clicking any of the following buttons and then clicking “Back” at the top, the error message below repeats. Thanks for any help.

Buttons: “Create”, “Play and Host”, “Dedicated Server”

Error message: “host id {0} has been already deleted”

Thanks for all the report!
Currently unable to look at it, but every report is noted and I’ll take a look at all that next week. The help to make that package as stable as possible is greatly appreciated!

Did anybody notice that the color is not being synced from the lobby player to the game scene player in the NetworkStarter example from Unity.

This is the same problem I’m having with my game.

Anybody knows how to solve it?

Thanks

Could you try with latest 5.1.2p2? The unable to read project ID error was a bug fixed in between those version I think, where project id wasn’t updated correctly.
As a temporary fix, you can try to type random thing in the project id, validate with enter, then paste your project ID again.

As for “Unable to load project” error, that is for the team behind the service. Can you confirm it is still happening so I can notice them of it?

When you say NetworkStarter, you talk about that package or the one posted in the 5.1 beta forum quite a while ago? Does your console in the editor or player log (inside youbuilname_data folder next to your build game executable) contains errors?

Hello UnityGuillaume,

Its the UNET demo written by Unity I just downloaded yesterday from the Unity asset store

I have Unity 5.1.2f1, You can see the problem if you run one instance as “Server only” then others as “Client Only”, then change the colors while in the lobby, then run the game, the color of the players in the game is always black, not the colors that was selected in the lobby.

Also the color synching dont seem to work too good while in the lobby.