- Home /
Network strategies for smartphone games
Hello there,
I am working with Unity for several months now, and I am finally working on the network part of my game. As I discover the common trap linked to network development (NAT and server reachability...) I wonder what is the best (or at least, the most common) strategy for a multiplayer game on smartphones.
The common strategy for PC/Mac games is to allow players, via an option pannel to configure their connectivity options. Also the game often warn players when connectivity is bad so they can configure their routers or their computer to play. Then it's easier for developers to build up a p2p communication between players thanks to option pannel and the computer nature.
But you can't ask players to configure their router or some other physical device when they are playing on a phone right? I mean, as long as you can play via 3G or Wifi and don't have a clue about your connectivity options (when you are using a public wifi access for example) you often can't modify gate access or stuff like that to enhance network reachability.
The few test I've done on my game (helped with some friends) led to complete connectivity failure due to NAT. As my phone uses wifi I'm not sure if ports are reachable or if my router allows NAT connexions because I'm not always at home, using my own wifi (the one I love, the one given by a well configured router).
So how do "real" games do stuff like multiplayer games on mobile? Is the most common solution to have a dedicated server reachable by everyone everywhere? What to say to players (who probably have bought a multiplayer game) when they actually can't play with others?
No, guys, seriously what is your strategy when you work for mobile phone...?
Answer by dscroggi · Sep 19, 2012 at 12:55 PM
Unity networking is pretty solid for small multiplayer, which is what it's designed for. Of course if you want hundreds of users you would need to go with an out of box solution like Photon, Smartfox, or roll your own. If you're designing a session based game with 4 users like Castle Crashers it would work fine. I've never had a problem being disconnected or whatnot and generally it connects on the first try with no issues. Try the Ultimate Networking package on the asset store, that did the trick for a small multiplayer game.
Do you use this specific package or every of your games work perfectly find without it?
I've used built in Unity networking for three games now. I wouldn't say any networking solution is perfect, but it works well enough. Depending on the method you use, some work better than others. I used a matchmaking system which produced a few problems due to the low number of connections. A lobby based system where players choose from a list of existing games manually may not have the same issues.
Anyway I'm working on a fresh solution now using .Net sockets. If you want a copy, I can e-mail it to you. It has semi-functional chat and position updates in a persistent world setting.
But, do your games run on smartphones? I mean... with no NAT troubles at all?
Yes, it does work. Here's a video of the game I'm referring to running on a smartphone, although it is not actually a multiplayer session.
Answer by Kiloblargh · Sep 05, 2012 at 05:14 PM
Buy Pro, then get Photon Cloud. They don't like to publicize this fact but built-in internet multiplayer on iOS/Android with Unity just plain doesn't work and making it work has never been a high priority. If it was, the Social API would already support GameCenter matchmaking.
It's also the reason why the $400 version of Unity iOS does not include use of System. Net but the $3000 version does.
According to your answer there is NO WAY one can make a cross-platform multiplayer game using Unity without suffering from connectivity issues without using a third party like Photon Cloud ?
Your answer
Follow this Question
Related Questions
Is this possible to make virtual host in real server? 0 Answers
Backend solution for asynchronous game 1 Answer
Unity knowing if connected to cellular not WiFi 0 Answers
Can't access "NetworkServer" 0 Answers
Screenshare to mobile device 0 Answers