Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Networking suggestions for authoritative, turn-based, basic movement/shooting game

Discussion in 'Multiplayer' started by xBrockSamson, Sep 12, 2014.

  1. xBrockSamson

    xBrockSamson

    Joined:
    Jul 21, 2013
    Posts:
    10
    I am part of a small group working on a relatively simple multiplayer game. We are all professional programmers and are familiar with most concepts behind multiplayer networking but we lack the experience in Unity to know about the exact implementation details and limitations of the various networking methods available to us. The basic functionality of the game is...
    • Each user has a persistent character which is assigned to matches via a matchmaking system
    • Matches are composed of 2 or more players and are essentially turn-based (round-based might be more accurate, as all players will take their single-action turn at the same time)
    • Gameplay involves simple movement and shooting (basic pathfinding, collision and hit detection)
    • We may or may not use a tile/grid system
    • There is no need for realtime network updates or physics
    The persistent characters basically requires us to use an authoritative model, but everything else is fairly simple. We could quite easily program all of the server logic into web API calls using PHP or one of the comparable alternatives. It would be fast, easy, cheap and scale well. The only real difficulty is that languages like PHP of course have no concept of the collision meshes in Unity nor do they have built-in functions for raycasting or other useful features. While we could implement these things ourselves (and using a tile/grid system would greatly simplify this) it seems like a lot of wasted effort for what is essentially duplicate functionality.

    If we write the servers with Unity we can utilize all these other funtions but there is so much out-of-date and conflicting information on Unity networking that we aren't sure what to make of it. Built-in networking, Photon, SmartFox or something else? Write the server code in Unity as a standalone app or have the server and client combined into one app with flags to determine the role? Our game is not a demanding program but what kind of overhead does Unity itself have that might create huge performance or user limitations down the line? Maybe a multi-session server would be worth the added complexity? Maybe even link the Unity libraries to a standalone C# app (if this is even possible?) to gain access to the Unity functions and data without the overhead of running the full engine?

    We are all actively exploring and researching our options but if anyone has any suggestions as to what options might be most worthwhile to explore (or avoid) we would greatly appreciate it.
     
  2. flaminghairball

    flaminghairball

    Joined:
    Jun 12, 2008
    Posts:
    868
    I haven't heard of anyone using SmartFox in a while… For realtime games the two big ones are Photon and Bolt Engine (both excellent). TNet is quite good as well. None of them provide any persistence layer out of the box, so you'd be looking at writing that yourself anyway.

    Keep in mind that running physics on a server doesn't mean running Unity physics on a server - for example it might be easier to chuck an open source physics engine onto your server, and then write a simple editor script to allow you to define your collision boxes in Unity that integrate with said physics engine. It depends on the specifics and where your competencies lie.

    One of the side-projects I'm working on is a persistent intelligent database (accessible via C#), initially targeted at turn-based games such as yours. If you'd like some one-on-one (or one-on-two - I've got a dev I'm working with) consultation, I'd be happy to devote a few hours to helping you hit the ground running as this is a great topic of interest to me. Feel free to send me an email (lincoln@troggy.com) or add me on Skype (flaminghairball).
     
  3. fholm

    fholm

    Joined:
    Aug 20, 2011
    Posts:
    2,052
  4. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,102
    Well the most popular networking options are photon and unityPark suite for unity games.
    You don't need any unreliable realtime communication and will probably use mostly reliable messages.
    uLink can use unity as servers and also MuchDifferent has the option of supporting some unity features outside of unity.
    by using uLink and their groups feature you can run multiple games on one server (since you don't have a lot of communications). The suite which consists of uLink for networking, uLobby for lobby functionality from accounts to friends and more, uGameDB for a free scalable database and uZone which can automatically monitor your infrastructure and manage server instances.
    This is the most powerful and mature solution used in many big titles like transformers universe, badanamu Korean MMO and behavior interactive's upcoming warhammer 40k eternal crusade MMO projects.

    Feel free to add me on Skype, contact MuchDifferent's support or sales to discuss unityPartk suite technically.

    the website of the suite is www.muchdifferent.com and the developer website is located at developer.muchdifferent.com

    Photon is a message relay which can send your reliable and unreliable messages but lacks powerful constructs inside unity, any built in support for instance management and databases and ... They have samples for some of these and some might be added later on but at the end they have a different philosophy and only provide a low level and kinda primitive message sending capability without even supporting serialization. I don't want to be rude and am affiliated with MuchDiffernt but this is my humble opinion and can be investigated by you yourself.

    Unity's built in networking is updated rarely and doesn't support any specific lobby/instance management/ ... kind of functionality and bolt is a new comer and I don't have much to say about it. Don't know much in fact.

    We've used Muchdifferent's tech successfully on a small virtual world project and a realtime 3d tank game.
     
  5. xBrockSamson

    xBrockSamson

    Joined:
    Jul 21, 2013
    Posts:
    10
    Thanks for the replies. I'm going to contact my partner and we will discuss them in more detail and might contact some of you. In the meantime, I thought of a better way to explain our goals. Think of something like World of Tanks except that the actual matches are essentially turn-based. I also made a step-by-step overview of the game stages and networking requirements...
    1. Upon starting, the client connects to the master server and logs in
    2. Master server loads the players persistent character data and sends it to the client
    3. User is able to make changes and decisions about their persistent character (research, upgrades, modifications, etc), chat/friend/group other users, and perform other common functions of similar games
    4. When ready to play they enter matchmaking queue and our systems determine their ladder opponent(s)
    5. Once matched, the server launches an instance of unity to act as the authoritative match host, and the players will be connected to this.
      • Clients may or may not maintain connection to the master server for chat/friend/group purposes
      • At first the match hosts will be started on the master server, but as demand grows there will be one or more physical machines dedicated to hosting as many instances of the unity match host as possible (hundreds or thousands per physical machine?)
      • There is no physics or complex features and the only reason to use Unity as a match host is to handle movement collision and hit detection. Otherwise, basic PHP/C#/anything can do the work just fine.
    6. The match proceeds in a round-based fashion (turn based pace, all players take turn at same time), with the networking requirements consisting of basic json data being sent just every few seconds or even minutes
    7. When match is complete, the match host will report the results and stats back to the master server and terminate
    8. Players exit match and repeat the process from step 2
    We want to handle the databases, login/authentication, character/menu/lobby interactions, matchmaking/ladder, chat/group/friend systems, gameplay structure and logic and stat reporting and tracking ourselves. If a tool can provide a basic framework for any of these things that is open enough that we can modify it to our own needs then it is an advantage, but the lack of any or all of these features is not a drawback as we assume we will have to do it ourselves anyways. All we really want is a way to easily send json data (strings) between the master server, match hosts and clients without having to worry about individual packets or NAT issues and a way to spawn and manage the match hosts themselves.

    If it is not possible to run so many instances of Unity on one physical server to act as match hosts or there is no reasonable way to manage and maintain them then we are open to alternative suggestions. One would be to handle the movement collision and hit detection ourselves. If we do that we can essentially make the entire set of server components ourselves using PHP/C#. It would be fast, easy and scale well. The drawback is that without the collision or hit detection features of Unity we might have to simplify some aspects of the game (use a tile/grid system instead of free/open maps, hit detection that uses mathmatical formulas instead of true line-of-sight checks).

    There may be other alternatives as well. Is there a way to load a dll or library from Unity into a standalone C# program in order to load collision data and use those functions? Would Photon Turn-Based, PUN or Server, SmartFox2D, uLink or any other 3rd party solution provide the framework for what we need?
     
  6. npsf3000

    npsf3000

    Joined:
    Sep 19, 2010
    Posts:
    3,830
    May I suggest you take a look at cloudspark.io/system/Academy.html and tell me what you think of it.

    I've been working on it for a little while now, and it's intended to give the control back to the developer - it gives you all the power of the cloud through C#.

    For example, compared to uLink (which is a pretty decent platform, I was an early adopter and the team behind it is pretty cool) you don't have to learn a new API, nor do you have to worry about setting up or managing servers (which is a pain in the behind). You would have to write code to handle the little physics you do want implemented, but that's generally not too hard (plenty of online stuff) and saves you from the overhead of Unity.

    So yeah take a look and tell me if it's something that interests you. If it is, I'm happy to work with you to make sure everything goes smoothly.
     
  7. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,102
    @npsf3000 thanks for the good words man!

    @BrockSamson Actually if you take a look at UnityPark suite's demo you see something similar to what you want.
    The demo has a lobby which players connect to and request a game, An instance will be created and then player will join it. The sample game instance is just character movement which is synchronized for all characters but the structure is there for changing the game.
    A lot of videos about that will be published, the code is easy to modify and reuse and we all are always there to help.
    http://developer.muchdifferent.com/unitypark/Tutorials/UnityParkSuiteDemo

    The demo code is provided as is but there is even consulting service if you need help as well. MuchDifferent is open for feedback and we've implemented user requested features a lot.
    MySQL support for uLobby and database agnosticism.
    Easier to configure and use uZone
    Group features in uLink and a lot more are all user requested features.

    In addition to what is mentioned above, there are specific new stuff like the uTest testing framework and our load tester which can be used for load testing your game servers to see how many games your server can handle at the same time.
    The load tester consists of lightweight unity clients written in pure C# and you can instantiate 400 clients easily on a normal system and you can use multiple machines to test for example 3000 players at the same time.
     
  8. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,018
    @BrockSamson: Actually, Photon Server is maybe not too bad for your intentions:
    It is C#, does not force you to use a specific DB or abstraction layer and has the APIs to scale it across many machines. You can use the built-in serialization (yes, there is one, despite common believe) or send your JSon as strings in Photon messages.
    Matchmaking and storing a game's state should be straight forward (we do that in Turnbased and could provide code).

    The big issue to solve would be to export and run physics (or at least collision detection) in the server. This is not built-in.

    You would basically swap the challenge of "getting everything else into Unity" for the challenge to "calculate movement and hits in a server".

    In best case, you would try out two or three engines with a prototype and see if you get along with those.
     
  9. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,102
    @tobiass Sorry if I said something incorrect about photon but what I mean was that you don't have any built in mechanism to store aserializer for type x and then just say write x to bitstream/buffer/...

    Can u let me know how it works? I remember it was possible to serialize some of the primitive data types.

    btw our database is not mandatory and the socket abstraction layer is a genius in design. It's a small interface which if require will put a lot of power in your hand. If you are just a user of it then it's only 1 line :)

    The family guy online game made most of unityPark suite features on top of photon, ask their team to see how much did it take them to do so. Our instance management part uZone for example runs good for many games including shadowgun dead zone but can be removed / not used if you don't need it. And match making is not the complex part :) Message packing and batch send,(prioritization with user controlled policies : not released to the public yet), powerful serialization and time synch and good measures against DDos attacks and a lot more are things which we are really proud of
     
  10. soaring

    soaring

    Joined:
    Jun 22, 2015
    Posts:
    27
    I know this is an old thread. But do people know if uLink is still supporting Unity? I noticed that the last update on their UnityPark stuff appears to be back in 2014, and their demo is no longer in the asset Store.

    We are very interested in creating a server-authoritative game, and uLink still seems to be the only option?
     
  11. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    463
    There are a handful of server-authoritative options. Are you looking for something different from the OP?
     
  12. soaring

    soaring

    Joined:
    Jun 22, 2015
    Posts:
    27
    Our goal is actually to build a game that would be most similar to ClashRoyale. So, "near-synchronous" gameplay, not as fast as FPS, but works on mobile+cellular network. The part we are struggling with the most is how to have an authoritative server. We have a pretty small team as well..

    We've been looking at Photon, uLink, and Unity's latest networking API. Our observations (and preference thus far):

    - Unity: Just noticed there is now a headless linux build option. we are checking it out.

    - uLink: Based on @Ashkan_gc's feedback they seem to have a pretty robust solution that utilizes Unity as the authoritative server. But based on the website updates, it's not clear if uLink is still been actively updated & supported.

    - Photon: Seems like their public cloud is peer-to-peer, but their enterprise cloud can support authoritative server. However, my impression is that we would need to build the server from the ground up (vs use Unity)..
     
    Last edited: Apr 7, 2016
  13. Ashkan_gc

    Ashkan_gc

    Joined:
    Aug 12, 2009
    Posts:
    1,102
    Hi current state of uLink is that we are not maintaining it actively but if it supports your needs and platforms then contact sales of muchdifferent and get a source license.
     
  14. Garry_garry11

    Garry_garry11

    Joined:
    Jul 16, 2016
    Posts:
    2
  15. Garry_garry11

    Garry_garry11

    Joined:
    Jul 16, 2016
    Posts:
    2