1
\$\begingroup\$

I built a casual game where the user answer the right word in random question. Now I want to make this game multiplayer (4 players) working on smartphones and tablets (Androird & iOS) where all the players are clients but one of them is Host/Client who receives the in-game answers to check who won and answer-back to the other three players (Clients) with the score.

However, I'm confused about HLAPI, LLAPI, dedicate server, PUN, Standalone, Local, LAN... I'm a mess right now. What should I choose? having on mind I only send/receive strings, and the game should work with and without Wi-Fi connection.

\$\endgroup\$
1
\$\begingroup\$

While asking for what technology to use is off-topic here... I can tell you what not to use.

First of all, you want the game instances to be able to work as clients or servers. There will not be an stablished server to which everybody connects. That is, you want a peer-to-peer network architecture. Please note that while we are talking P2P, that does not mean there will not be hosts.

See How can I make a peer-to-peer multiplayer game?.


The issue is that if you want smartphones to connect without Wi-Fi. Which often would mean mobile telecommunications technologies (3g, 4g, etc.) - As I was explaining in What are my options for building a centralized server architecture for a Unity game? that has a lot of limitations for P2P.

So, you have three main paths:

  • Stick with mobile networks.
  • Use something else. You could use Wi-Fi which is Local Area Network (LAN). alternatively consider Bluetooth, which is a Personal Area Network (PAN).
  • Have a server. Clients could access the server over the Internet either from a mobile network or Wi-Fi (via a gateway).

To be clear, Wi-Fi could be used to connect directly, since it is a Local Area Network (LAN), or to access a geteway to the internet.


If you want to stick with mobile networks, these won't help you (they are still useful over Wi-Fi):

  • HLAPI. Won't work because it relies on knowing the IP.
  • LLAPI. Won't work because it works via web requests, which imply a web server.
  • UPnP hole punching will probably not work either. It requests the router to Open and Forward a port. Just don't count on it on a mobile network. You didn't mention it

By the way, I do not think Standalone means what you think it means.


You might also be interested in:

  • STUN: NAT traversal. There are some free public STUN servers. They are used to try to stablish a direct connection
  • TURN: Relay servers.
  • ICE: "A standardized set of methods" built ontop STUN and TURN.

You might also be interested in WebRTC, which uses the above and also provides audio and video transmision via RTP and SDP, although I do not think there is - at the time of writing - a WebRTC solution you can use from Unity. I guess it is worth to have a look.

I suppose another solution is a Virtual Private Network (VPN). The clients connect to a VPN server over the internet which relays the connections in such way tha they appear to be on a LAN. Although, I do not know how you would do that programatically on smartphones. If it is possible at all. Usually end-users will acquire a VPN service when they need it. And I mean a true VPN, no a "hide my IP via retransmission while I enter this website" thingy (web proxy).


If you are considering a server, you might be able to use Amazon Lambda, Cognito and DynamoDB, instead of having a fully fleged server. There are also inexpensive hosting solutions that are useful for low traffic.

See: Can Cloud Functions be used for a multiplayer game server?.


See also:

\$\endgroup\$
  • \$\begingroup\$ Your answer is very complete but I was reading about P2P. uNet HLAPI is P2P, and Photon bolt also, however I don't know how to use them, all this APIS are pretty focused on player position like Vector3 & floats, but have no any option to send/receive strings, what do I really need? I read about Unity NetworkTransport class, is that ok?. By the way, about this "The issue is that you want smartphones to connect without Wi-Fi" this is optional, meanwhile I can only work with Wi-Fi and Android. \$\endgroup\$ – Lobsang White Jun 20 at 22:02
  • \$\begingroup\$ @LobsangWhite yeah, HLAPI will do P2P, yet it is not what you need for a mobile network. About sending strings instead of Vector3 et.al. what you need is a lower level library. Forgetting the mobile network for a moment, for a list and comparison of .NET libraries you could use in unity, have a look at BenchmarkNet (which I mention in a linked question). Yet, for P2P on a mobile network, on Unity, I don't know what to Recommend. In fact, I want to create a STUN based solution myself... I have code based on LumiSoft.Net, but it is not there yet. \$\endgroup\$ – Theraot Jun 20 at 22:11
  • \$\begingroup\$ @LobsangWhite I have modified the answer to reflect that Wi-Fi is optional, and to clarify that I meant HLAPI will work on Wi-Fi but not on a mobile network. Also added mention of "serverless" (there are servers, not on your control) "microservice" (a function - in the case of lambda - or an entity - in the case of dynamoDB - are microservices) "cloud" (that has become synonymous with "online", although it should be something closer to "distributed computing") solutions. \$\endgroup\$ – Theraot Jun 20 at 22:39

Not the answer you're looking for? Browse other questions tagged or ask your own question.