- Home /
Question by
NeTRo-DZ · Jun 30, 2015 at 07:47 AM ·
multiplayerserverconnectiononlinematchmaking
can i make a matchmaking without choose server
hey i know now how to make a in unet and how to connect to it with the matchmaking by select server
but ... can i connect to server without choose a server (click connect and the game is select a rondom server)????
Comment
Hello, do you $$anonymous$$d accepting my answer since it is correct. It really makes me stay motivated to answer these questions.
Answer by AurimasBlazulionis · Jun 30, 2015 at 08:19 AM
OK, there's what you have to do: Get the server list to an array. If you are building UI from some server list array, then you should already have it. Second, get length of the array using this:
lSize = serverList.Length();
Generate a random number using Mathf and Random combination
rServer = Mathf.RoundToInt(Random.Range(0,lSize-1);
And then connect to server, use this if you use standard unity networking:
Network.Connect(serverList[rServer]);