- Home /
Basic Multiplayer Question
Hi all ,
At very First time am working on 2 player multiplayer game, i'm getting much struggle with basic concepts. Actually i saw the basic on M2H tutorials and Photon network and etc.
Actually i have a button "MULTIPLAYER", When a user hit on the button am Initialising and starting a server using "Network.InitializeServer" and he acted as a server . its started my server fine.
Now my question is another user coming to play the game if he hits multiplayer button, he wants to be join with the device which is already initialised the server (this one should act as client), here how i can able to find a device (i.e A User) already initialised a server ? if there is no server initialised he wants to be act as server. How can i make this ?
Hope you guys got my question. Thanks.
Please clean up the gramma. I can't really understand what you mean in your question
if(more than 0 servers with enough room)
JoinServer(Data);
else
Network.InitializeServer(Data);
I am using the PhotonNetwork myself, so I do not know with the default Unity3d Network, but I get the amount of servers/rooms using:
PhotonNetwork.GetRoomList().Length //Or something like that
If this returns more than 0 I would join a random room using
PhotonNetwork.JoinRandomRoom(data) //Or something like that
If it returns 0 (which means there isn't already a server/room running) then use
Network.InitializeServer(Data);
You should be able to do similary using Unitys own Network solution.
I would recomend using Unity3Ds build in Network class ins$$anonymous$$d of using PhotonNetwork... In Unity3Ds Network class you can simply write Network.Connect(IP, PORT, "password");
and you connect to the specified server with the given IP-adress
Your answer
Follow this Question
Related Questions
Unity networking tutorial? 6 Answers
Unity Multiplayer Design. Is it complicated to implement and learn? 1 Answer
How can multiple network players control one gameobject? 0 Answers
Unity Networking. Player flickers. 0 Answers
Networking Player Nametag 1 Answer