Search Unity

Help Me Choose Networking Solution for Formation Tactics Game?

Discussion in 'Multiplayer' started by Gabe851, Sep 24, 2022.

  1. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    32
    Hello! I just have a general question about which kind of networking (netcode, mirror, various photon products, etc...). I ought to use for a project. The idea is something like (and I have a singleplayer prototype), a real time, total war type multiplayer only formation tactics game that is:

    1. 1v1 only
    2. multiplayer only, no campaign
    3. doesn't require leaderboards or any persistent data stored about players
    4. but I would like to have some kind of authentication
    5. hopefully some anti-cheat (whatever is available with p2p? or do you really need DGS for anti-cheat?)
    6. lobbies for players to host and join games, rooms where after joining you pick units, a game where those units deploy/fight, and a chat system both in the lobby, in rooms, and in the game, and hopefully ability to reconnect disconnected players (at least in the lobby/first room, if not in game)
    7. because it is a formation tactics type game, I would only need to network the formations themselves, and their state (so basically a transform + some info about number of men remaining, cohesion state, whether running/walking/fighting, status effects, etc...), only syncing about 10-20 formations per side
    8. and the individual men would be recreated on each client just as a kind of elaborate visual, but their individual positions would not need to match exactly over the network, as it is whole formations that are moved around by the player and determine fighting outcomes, ie individual 1v1 fighting not simulated, only the formations themselves are gameplay relevant.
    9. it would be slow paced, have no need for any aiming or fps type low latency or client prediction requirements, and it would even have intentional order delays, so basically just syncing the movement and state of total up to about 40 formations between only two players, moving slowly, and with pretty high latency being tolerable.

    Would Photon's PUN2 be sufficient for that? For authentication and lobby hosting do you need dedicated game servers, or can PUN do that? Would netcode be better? I've done some PUN and Mirror tutorials, and PUN seems pretty easy, but I want to make sure I don't run into unforeseen performance issues mid development. Unity's netcode for gameobjects with relay/lobby/authenticate also seems good in theory, but is relatively new and maybe not as well established or easy to use as PUN? Is there any obvious best solution for this sort of thing?

    Thanks for any help.
     
  2. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
    It seems like literally anything would work to be honest.

    PUN2 I think covers a lot of your requirements except anti-cheat, because it's client authoritative making it very easy to cheat. Fusion is another option that has lobbies, chats, ect, and is server authoritative. If you are developing for fun Fusion may be a good choice. Keep in mind though that like PUN2, it does come with a price tag.

    If you want a free option I recommend mine, Fish-Networking. It outclasses other free options in many areas. Downside, no built in lobby system; you would need to use a third-party service such as Steam or EOS.
     
  3. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    32
    are there any issues with still using PUN2? some people were saying that Fusion renders it obsolete, or is that not true? what's the difference in complexity of setup between them? From reading about it, it seems like Fusion has plenty of advantages in general vs PUN, but not necessarily ones that would make a difference for my use case, so not worth it if much more complex to setup. Is Pun2 likely to lose support soon?

    I may want something with a built in lobby system, as I'm not looking to deal with making that myself or get caught up integrating more third party stuff for an already third party networking api. or is it recommended to use steams's for games released on steaM?
     
  4. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    Photon costs money, which is a problem.
    If you are going to release your game on steam, steamworks might be the best for you since:
    -Its free (If you release your game on steam, which is 100$)
    -It works through a relay, so no IP leaks.
    -Lobby system that works with steam friends.
    -Anti cheat
    Mirror, netcode and FishNet have a steamworks transport, so I will recommend you to use the one you find the easiest to use.

    If you dont want to release your game on steam, EOS can offer the same for free, but only mirror has a EOS trasnport (And FishNet will have one)
     
  5. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
    Didn't mention you'd be using Steam earlier.
    FishNet will work fine for your needs using our Steam transport.

    I have no authority to speak on the life expectancy of PUN2 but if you want anti-cheat you really shouldn't be looking at PUN. Fusion is their new server authoritative technology for anti cheat.

    Ultimately if you want anti cheat you either need Fusion, paid. Or a free solution with steam support. Heathen Engineering has a free steam package to get started as well. I can say with certainty it's fully supported with FishNet.
     
  6. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    32
    maybe i misspoke. I would like ultimately to release such a game on steam, but I don't know if that means that I will need steam's online services? Like a game can be bought and downloaded from steam, but the online play is all through something else, like mirror, netcode or fishnet, right? But, PUN doesn't work with steamworks like those others? What is a steamworks transport?

    Does steamworks replace the multiplayer networking api stuff in the game code that say PUN does, or does it work with PUN or other networking APIs as a wrapper to just provide matchmaking, lobbies, and such?

    For fishnet, I would need to use it, heathen engineering, and steamworks, to go through steams networking services? Sorry, I'm a bit confused about what exactly is the purview of all these different services.

    Thanks for the help!
     
  7. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
    You can use Steamworks with most networking solutions, FishNet, Mirror, Netcode. I do not know about PUN but I'd imagine so to some degree. Steamworks is basically the code to simplify communications with Steam.

    Heathens is an asset that makes using Steamworks easier; it has a lot of built-in functionality such as rooms, friends, ect. You could do all the stuff that Heathens does with only Steamworks but you'd have to write it yourself, which is why I recommended Heathens Engineering's asset.

    There is one final layer, the 'transport' layer. This is used to send data between your client/server to/from Steam. So Steamworks and Heathens is a helper layer, the transport sends the data from the helper layers.

    I realize I probably made this really confusing for you because I'm at times not great on explaining things. TLDR version is you can use Steam with virtually all networking stacks and there's a lot of free tools to make it easy. I cannot speak for the difficulty of others, but in FishNet it's pretty darn easy. It can be as simple as importing assets, adding a component and editing a few fields.
     
  8. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    32
    ok cool, and yes I'm confused in general about this but it's hardly your fault lol, there are just so many options and services.

    For my specific use case, are there advantages to fishnet over PUN? I don't think I require features like client-side prediction, lag compensation, or server sharding (or servers at all even), but as I'm a solo developer (mostly gameplay/ai/animation programming) and not a specialist in networking, something that's easy and has lobbies say already built in, and lots of existing tutorials etc...would probably be best for me. IE, the easiest thing possible that still (if barely) has what I need. Even the advances in Fusion over PUN I don't think would be necessary for my use case, but I'm just not sure.

    There is of course also the new unity netcode for gameobjects (and for DOTS w/ DOTS 1.0 release eventually...but who who knows when), but Unity has a bad track record of abandoning things, and although there are some sample games for it, it won't have the same kind of existing basis of reliable documentation and years of forum posts as something that's been around like PUN.

    Thank you for your time! I'll keep on doing tutorials and see where I end up.
     
  9. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    The advantage of using FN is that its free, and, since you use the steamworks transport, you also have anti cheat, which PUN doesnt have it.
    If you make the game with PUN, you would have to pay 95$/month if you want more than 20 CCU, while FN and steamworks would allow you to get any number of CCU without paying anything.
     
  10. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    32
    ok thanks, although i think PUN is $95 a year for up to 100 CCU, and 95$ a month for up to 500. I think that even having 20 people playing a game i solo make at a time would probably be a bit optimistic on my part lol, but still free is free.
     
  11. CreativeChris

    CreativeChris

    Unity Technologies

    Joined:
    Jun 7, 2010
    Posts:
    457
    We do have a dedicated Discord server with a few years worth of content, and a thriving community where you can ask questions, all very useful. You can make use of our sample games and documentation, and we also write educational content for multiplayer development. We continue to invest in these areas, expect it to grow and improve over the coming months/years.
     
  12. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    My recommendation is to start with Unity's networking for gameobjects. At this point it's important to just use whatever is free to use, and move forward on that.

    If you need to pay for something later, you won't lose anything having learned the basics with Unity first.

    I agree DOTS networking is a bit far off for your use-case.
     
  13. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
    PUN
    --------
    Pros:
    - Lobbies built-in with potential match making.
    - Really easy to use.
    Cons:
    - Paid (price varies depending on needs, please research this yourself).
    - Client authoritative, easy to cheat.

    Fusion
    --------
    Pros:
    - Lobbies built-in with potential match making.
    - Server authoritative, difficult to cheat.
    Cons:
    - Paid (price varies depending on needs, please research this yourself).
    - Slightly more difficult to pickup over other server authoritative options but probably not an issue once you're rolling.

    FishNet
    --------
    Pros:
    - Most feature rich and efficient free HLAPI solution.
    - Server authoritative, difficult to cheat.
    Cons:
    - No lobbies built-in, but can be done with free third-party assets.

    Other free choices
    --------
    I'm not going to cover other options because I do not believe I could adequately do so in depth. If they do hold advantages over FishNet I'm sure someone else could tell you.


    Conclusion
    --------
    You said you need anti-cheat so I'm going to exclude PUN as a choice since it cannot provide this. The others are still considered.

    Secondly, you wanted lobbies. You can go with Fusion which has lobbies built-in but will have a price tag depending on your needs. Or a free option which has lobbies via third-party, but will probably require a little more work to get such features in.

    If you just want to get your feet wet I recommend Fusion. It will get you started without overloading yourself with too many tasks. If you are expecting this project to scale I'd personally put the time into a free option and learn the tools.
     
    wangsitan likes this.
  14. Gabe851

    Gabe851

    Joined:
    May 13, 2017
    Posts:
    32
    thank you so much for the thorough reply! I will try out at least the tutorials/samples for fishnet, fusion, and netcode for game objects, in addition to PUN2, just to give them each a fair shake. I'm ok with paying a bit of money ($95 for a year is not a showstopper for me). I probably value ease of use over effective anti-cheat, so if PUN is way easier than fusion I may go with that, but if Fusion turns out to be pretty easy too then maybe it's a better option even if I don't need the advanced stuff. I'd like to give your fishnet, and also unity netcode, a go as well. I'll check back in here once I've had the time to at least fire up the tutorials on all of them and get a good sense for what they are like in practice.

    thanks again everyone!
     
  15. r31o

    r31o

    Joined:
    Jul 29, 2021
    Posts:
    460
    I still think that Fish-Net/Netcode/Mirror with steamworks covers everything.
     
  16. mischa2k

    mischa2k

    Joined:
    Sep 4, 2015
    Posts:
    4,347
    This is a broad topic, with different stages of protections that you should be aware of.

    Server Authority
    It would be wise to implement almost all game logic with server authority first, before worrying about client sided anti cheat.

    For example, if a player's health is client authoritative then no amount of client sided anti cheat will protect you from hackers attaining god mode. Where as with server authority, you would not ever ask the client about the current health. Instead, the server would tell the client about its health and make all decisions related to health, and validate all of the client's requests related to health. For example, when requesting to use a potion, always ensure the player actually owns that potion, is not dead, etc.

    This essential makes health unhackable, unless you are able to access the server machine.

    However, certain aspects like movement can be quite hard to make both responsive and secure.
    It's certainly possible to implement all of your game state with server authority. Even for movement, where you might move the client immediately, send the movement to the server, validate if the move was legal, and then accept / reject it.

    Minimizing client information
    That being said, clients may still gain advantages by simply reading state from memory without manipulating it.
    For example, if your tactics game accidentally keeps all of the enemy's positions in memory, then hackers may attempt to extract it for their advantage.

    In this case, it would help to only send relevant information to the client. For example, many netlibs provide customizable interest management. You could implement Raycasting with some tolerance in order to check if a player sees another player's units. Otherwise, don't even send it to the player at all (in which case it can't be extracted from memory).

    Client sided anti-cheat
    Lastly, even if your game is server authoritative and minimizes information sent to the client, there may still be cheats. For example, auto clicks, farm bots, aim bots and such.

    This is when you should start worrying about client sided anti cheat.
    But keep in mind that this is a catch & mouse game that you will not win, only delay.
    Reverse engineers have sophisticated tools like IDA, Ghidra, Ollydbg, Ollydbg, MHS etc. to circumvent client sided anti cheats, and you will most likely not be able to compete with them all on your own.

    Some popular games need to move their anti cheat software out of userspace into the kernel, where it's harder for hackers to circumvent it. If your game is popular enough, it will be circumvented eventually.

    This is a very broad topic and there are lots of things you can do that I haven't mentioned, like obfuscation (you should at least use IL2CPP instead of shipping IL code), virtualization, etc. But as mentioned, it would be wise to start with server authority & minimizing information sent to the client :)

    On a side note, imho attempting to protect client sided hacks isn't ideal.
    Instead you should try to silently detect hacks, and then ban hackers after random amounts of time. This way a hacker would not know which particular action was detected.
     
    Last edited: Sep 28, 2022
    ThatDan123 likes this.
  17. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    401
    If you are open to going the paid route I encourage you to try Fusion, not PUN. It's server authoritative and considerably more modern/optimized, and more features than PUN. I rarely recommend paid solutions over mine but it sounds like you could benefit from Exit Game's integrated systems.

    And you know where I stand on my free recommendation :p FishNet has pretty much everything Fusion does except the lobby stuff built-in; including real-time secure movement.

    Good luck on your journey!
     
    CreativeChris likes this.