Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Resolved What is the optimized multiplayer solution for a card game?

Discussion in 'Multiplayer' started by Leos-Clockworks, Dec 3, 2022.

  1. Leos-Clockworks

    Leos-Clockworks

    Joined:
    Oct 27, 2017
    Posts:
    18
    Hello,

    I've been looking at:
    1. Pun - https://www.photonengine.com/pun
    2. Netcode for GameObjects - https://docs-multiplayer.unity3d.com/netcode/current/about/index.html
    3. FishNet - https://fish-networking.gitbook.io/docs/

    And wondering which of them or another option, is most suited for a simple card based game.
    Card games don't usually send a lot of data, mostly what card is used and by who. I researched the options, all look great, but I'm not sure about how robust they can be.

    PUN looks like the more stable long term product out there, while NGO has just released. And FishNet seems to be missing some bigger features.

    PUN and NGO both have Lobby infrastructures:
    1. https://doc.photonengine.com/en-us/pun/current/demos-and-tutorials/pun-basics-tutorial/lobby
    2. https://docs.unity.com/lobby/unity-lobby-service.html

    What option would you recommend for a simple card game?
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    "simple card game, little traffic" => with those specs just pick the one that's most convenient to use.

    Take NGO simply because it's from Unity which means it'll have the best support and most tutorials, while integrating well with Unity Gaming Services. While NGO only recently reached v1.0 it has been in development and proven itself under the name MLAPI over several years.

    If you mean "services" (Hosting, Relay, Lobby, Matchmaking, etc) then these are, strictly speaking, not part of any networking framework.

    Both Unity (UGS) and Photon offer such paid services, Fish-Net is not because it's purely a networking framework (like NGO) but you're free to choose / implement your own services and hosting, meaning no vendor lock-in as with UGS/Photon.

    For a comparison of actual networking features (Mirror, Fish-Net, NGO) see this thread: https://forum.unity.com/threads/updated-free-networking-solution-comparison-chart.1359775/

    For a card game you don't need more than RPC calls and scene management.
    Tip in advance because I've seen developers try and make every card a synchronized NetworkObject: none of the UI / cards should (needs to) be a NetworkBehaviour.

    Instead you only need to confirm via RPC from the server that if a player wants to draw/deal/take a card, he is allowed to. Clients receive the "draw/deal/take card x" RPC from the server and subsequently play animations, fx and update the UI on each client independently. That means not sending a card's Transform data several times per second between server/client while it's moving, eg from deck to hand. The visual animations need not be synchronized with other players, they just need to be played locally, reducing traffic and code complexity.
     
    RikuTheFuffs likes this.
  3. Leos-Clockworks

    Leos-Clockworks

    Joined:
    Oct 27, 2017
    Posts:
    18
    Thanks for answering!

    I'm not that well versed in Networking so doing my research now and trying to pick the right solution to use and commit to.
    Both Photon & Unity Gaming services seemed like they cover pretty much everything I need and more.

    As you said, for a card game, almost everything is handled on the client side and only what move and by who is actually sent. Was just wondering if there was maybe something more lightweight as the others have lots of features for 3D animations etc that I probably wouldn't need.

    The link you sent was very useful, though its kind of hard to predict what networking features I might need.
    I am inclined to using NGO with UGC as its all by Unity and probably has the best combability between themselves.

    Guess I'll need more research before starting.

    Edit:
    It would be nice if I could make the game cross-platform, but it seems NGO doesn't support it if I read that correctly.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,533
    NGO supports cross-platform but there are restrictions I believe, or some untested platforms (consoles?). Or requires a different transport, for example if you want WebGL clients.

    As for lightweight, you could actually just use Unity Transport (or any other UDP transport) because you probably don't need time synchronization and all that stuff, just sending a message/data here and there would suffice. But it still requires writing and testing more code so I wouldn't recommend that.
     
  5. Leos-Clockworks

    Leos-Clockworks

    Joined:
    Oct 27, 2017
    Posts:
    18
    Ok, I see.

    Well, I guess I'll just jump into NGO + UGC and see how it goes.

    Thanks for helping me out
     
  6. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    389
    FishNet actually has a 'Lobby and Worlds' project which might be perfect for you. I actually made Lobby and Worlds specifically with card games in mind.
    It has a lobby system to allow players to join in and see other matches, and let's players create/join rooms of existing games. It does all of this on one server instance, optimizing use of RAM and CPU. It also eliminates the need for having to find instanced servers (match making) because it's all handled by the one server.

    FishNet also supports EOS, Steam, and Unity Relay. There's a Photon relay as well currently in public testing.

    Heads up on the Lobby and Worlds' project, it is considered a Pro perk so it has a one-time buy in of $10. But, you can replicate it without Pro and all the other mentioned transports are also free.

    More details about Pro as well Lobby and Worlds can be found here https://fish-networking.gitbook.io/docs/master/pro