- Home /
multi-player android and IOS
im about to start making my first multi player mobile game and i was wondering if it is possible to use networking in a way that the mobile devices themselves could be the server and client without using any other services, actually this is my first networking task, this is how i plan to make it let me know if it is feasible
player clicks multiplayer
mobile devices looks for another mobile device who is server without client connected
if thats is the case connect to that server device as client
if that is not the case connect as a server and wait for a client to connect
i was just wondering if that kind of senario would work where the mobile devices themselves could do all of the server client work
any advice is greatly appreciated, thank you for your time :)
Answer by Kiloblargh · Dec 08, 2013 at 01:38 AM
Yes. I'm making an iOS/Android/webplayer game for 2 players, and my networking is already working. "Without using any other services" is a tricky one. The most common noob solution is to use Unity's default Master Server. The problem is, it's only intended for testing, not guaranteed to be online every time you try to connect to it, and not meant to be used at the scale of a finished commercial game. Of course, most people never even finish their first multiplayer game and never achieve any amount of success or popularity if they do, so that never becomes an issue.
If you have the resources to host your own Master Server, it is very easy to achieve step 2. If not, you still have to have your own domain and will have to use WWWForm calls to access PHP scripts to connect to an SQL database. That is what I'm doing but I can't give you much help (I have 11 different PHP scripts that are pretty specific to my game) so you'll just have to read all you can about PHP elsewhere, prepare for a headache and stock up on the coffee.
thank you for your time, so Unity's default $$anonymous$$aster Server, how does that work, by the package name? to uniquely transfer information?
I'm not entirely clear on what you're asking. You do need a unique string for the "game type" but it does not need to match the package identifier. Have you read the $$anonymous$$aster Server docs?
Also, keep in $$anonymous$$d that all the master server does is matchmaking. Once you have joined a game, one player is the server, one (or more) is the client, and all information is going directly from one to the other, not through the master server anymore.
so what your saying is that using the calls to unitys master server cannot be used in a finished published mobile app?
"Should not," not cannot. I'm sure there are finished published mobile apps that use the default master server.
ok thank you for your time, i really appreciate it
Answer by Julien-Lynge · Dec 08, 2013 at 01:15 AM
What you want is called RPC. Please do a search for 'unity rpc', and check out the examples, script reference, etc.
Good luck!
can i use just regular Unity3d code for networking in a published mobile app? only unitys networking code and nothing else back end?