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

  1. player clicks multiplayer
  2. mobile devices looks for another mobile device who is server without client connected
  3. if thats is the case connect to that server device as client
  4. 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 :slight_smile:

What you want is called RPC. Please do a search for ‘unity rpc’, and check out the examples, script reference, etc.

Good luck!

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.