Hi all,
I’m thinking about online game, maybe like dota or LoL.
If I develop game like that using unity, how does the network?
it it Master server and Client (player)?
Should I customize the master server and add function authentication or other?
tl;dr
Networking is hard, even more so with account service etc. I recommend you start with something smaller. I didn’t and even though I share my knowledge now, trust me, you don’t want to go down this road. Come back to idea once you finished sth smaller.
Full text:
Note - I’m experienced with old Unity networking API, chances are the new one makes process easier.
Well, I assume you expected a nice and short solution, and unfortunately, there isn’t one. Personally I’ve never used master server, dismissing it as unreliable and undocumented, although this is just my personal opinion. Basically, you probably need following infrastructure:
- Service server - this is where players log in, pair up, do all “around game” stuff and, eventually, end up starting a game. Technically, it doesn’t have to (and actually shouldn’t) be Unity. It may be Unity (that’s what I do when I need to prototype fast), but should probably be C/C++ with sockets. I believe that’s what what Master server attempts to provide.
- Game server - instance of this application is started for every game players have started. In lol, this (presumably) happens when all players choose their heroes etc. It should be responsible just for game logic, never for the presentation. You need to make it as light as possible. This and service server need to be hosted on a publically known IP (probably static) IP, with forwarding properly set up.
- Game client - thats, well, the client. It connects to game and allows players to interact with game server. Note, that it’s up to you if this application includes
- (Optional) Lobby client - which is listed as separate application, but could as well be just a scene, if you setup your project correctly.
- (Optional, but recommended) Service database. All the account related stuff, progress players make, their transactions etc etc go here. SQL knowledge required.
- (Optional, but recommended) Service database api. This is how you access information from your database. There are easy to learn scripting languages out there, use one of these to wrap your service database and provide access to it via HTTP calls. If you don’t you may access your database directly from C# (or C/C++), which is totally viable option, but from my experience doesn’t scale up well, as your server will always need to be recompiled every time you change sth in DB.
- (Optional, but recommended) Client launcher/updater - you shouldn’t expect players to download new application every time there is a small change to it’s code - therefore they should start it via launcher/updater. If you played dota ot lol, you are probably familiat with the concept. For the record, there is a free asset on Unity store for doing it (with a piad option to customize it a little bit more), but I haven’t used it yet. There is also plenty of articles on the web explaining how to do it yourself.
Long story short - that’s a lot of work, probably requiring knowledge of several langages/technologies. Even though it is possible to do most of it in Unity, you should ask yourslef - is it wise to do it all in Unity? I guess you are not that experienced with network programming, in which case I highly recommend you start with something smaller. In this case, it would probably be some game played in local network, as you could get used to typical problems faced when coding asynchronous applications.
And then come back to your idea, it will be much easier to do it