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.

Question Which Multiplayer Solution for Fast Paced Shooters?

Discussion in 'Multiplayer' started by Juice-Tin, Nov 27, 2022.

  1. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    222
    Hello, I've have a fast paced side-scrolling shooter that I am now trying to make online multiplayer.

    I've tried Netcode for GameObjects which seems great, however clients can't spawn Objects, and require the server to spawn for them.

    The problem is that is a player has 100ms latency, shooting the weapon while moving causes bullets to spawn 100ms delayed, and behind the player, this looks and feels VERY bad.

    So my question:
    1. Which multiplayer solution handles this issue the best?
    2. OR, if this is a common problem everywhere, is there a solution? Like maybe let the player shoot locally, but then the server creates a visual-only bullet to where the player shot to simulate it syncing?
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,957
    The authoritative model is still the best for this kind of game.
    The shooting player should locally predict that the bullet gets created or that the shot happens. Usually, the server will confirm this and maybe there is a minimal correction necessary. In rare cases, when the server disagrees, then the local prediction was wrong and needs to be cleaned up. This may cause glitches but some can be hidden and in general the server is right and it's best that all agree.
     
    CodeSmile likes this.
  3. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    282
    I agree spawning locally. Server should handle damage and players just show visuals.

    Far as solutions go, Fish-Networking has a tick aligned simulation which makes this easy to accomplish. I actually am using the exact described behavior on a paid project with FishNet. https://fish-networking.gitbook.io/docs/ (links and more).

    I'm going to probably add a guide to this in the docs over the next few days; there's already a placeholder for it. https://fish-networking.gitbook.io/docs/manual/guides/lag-compensation/projectiles
     
    CodeSmile likes this.
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,882
  5. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    222
    Thanks for the info, looks like Fish-Net has the most features, though while using NGO so far I can definitely say it's quite easy to get going without much hassel.
     
  6. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    219
    Hey @Juice-Tin , FYI NGO is not recommended for competitive fast-paced shooters, as it's missing some much needed features such as prediction + reconciliation and rollback. It also doesn't scale well with large amounts of network objects (even though this really depends on what data you send about these objects).

    NGO is more recommended for games of up to 10 players per session/low amount of networked objects (think of Overcooked, Among Us, Hearthstone) where client-side prediction and reconciliation are not really needed (unless you're willing to implement them yourself)
     
    CodeSmile likes this.
  7. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    1,882
    I applaud such an honest statement! :)

    For future readers: prediction & reconcile is on the roadmap (currently "planned").

    I tried NGO, Mirror and Fish-Net recently and have to say, as far as getting started and ease of use is concerned, they're all on equal terms. ;)
     
    RikuTheFuffs-U likes this.
  8. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    219
    Thanks, @CodeSmile ! From my point of view, we're here to help. Picking the right framework from the beginning is important, as it is a decision that has an incredible impact over the project in the long-term.

    As a Unity user myself, working on multiplayer games, I'd hate if somebody gave me bad advice just to push a product of their company.

    Making multiplayer games is hard enough on its own already!
     
    tobiass, CodeSmile and hippocoder like this.
  9. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    222
    Thanks, I appreciate the honesty as well. 10 people max sounds fine, however there are TONS of bullet objects are very fast paced movements happening each frame, so it's definitely something to consider.

    With my 0 networking experience, I had a working online demo with join codes & server list in my existing game in just 2 days thanks to unity Relay & Lobbies taking care of all the server side stuff.

    I hear Mirror/Fishnet/Photon/etc requires your own servers & server code to connect with, which again, 0 experience. (Also on a VERY tight deadline for this, 2-3 weeks max)

    Does Fish-net have any simple Relay/Lobby system that automatically handles all the server-side stuff? Every tutorial I've seen only shows how to connect 2 clients locally.
     
    Last edited: Nov 30, 2022
  10. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Yeah. I think since Unity bought Rival recently for DOTS, and that contains a twitch shooter sample, it might be worth a look for projects starting out now. What do you think?
     
  11. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    219
    @Juice-Tin Do they really need to be networked, though? More often than not, you can get away with raycasting on the server and notifying clients about being hit.

    @hippocoder I'm not an expert of Netcode for Entities ("""the DOTS version of NGO""") or DOTS in geenral, so I'm not sure of what the consequence of that purchase will be... Something seems to be moving, though!
     
  12. Juice-Tin

    Juice-Tin

    Joined:
    Jul 22, 2012
    Posts:
    222
    @RikuTheFuffs-U Sort of, here's a clip of a 6v6 with AI bots using rockets, physics-based grenades, ragdoll physics (which are important, as dead bodies also block bullets)
    https://i.gyazo.com/bc2f5f4f2f31667fcf019c3c32ec0f6e.mp4

    My concern now is because it's so fast paced, even a small delay in: "client shoot > server authenticate > tell client" could feel like an eternity, which may be exaggerated based on the amount of networked game(and physics)objects required.

    Happy to try out Fish or Photon, just can't figure out if their online setup is as easy as NGO Lobbies/Relays was. Can't find much info on it.
     
    Last edited: Nov 30, 2022
  13. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    282
    I wanted to let you know that I finished the guide today. The code examples naturally are for my networking solution but I'm sure it could be converted to anything. There's a preview of the outcome as well so you can see the results before diving into the code.

    If the page still says 'coming soon' you may need to refresh it.
    https://fish-networking.gitbook.io/docs/manual/guides/lag-compensation/projectiles

    EDIT: here's the preview with a large ping of 220ms.
    PredictedProjectile_00.gif
     
    Last edited: Nov 30, 2022
  14. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    2,957
    I just checked out your video. Looks nice.
    You've been open to using Photon solutions, so I think it's OK to add some details.

    If it wasn't "finished" already, I'd say it's a perfect fit for Quantum. It is deterministic with predicted movement and can do a few nice tricks. E.g. you could actually implement jumping on (or just over) a flying rocket. See the Quantum Demo "Blueless". There is also a Bot SDK, which helps populating multiplayer games.
    It works especially well for mobile games, as our servers coordinate the input and no host / server is needed on top. This also means, it does not matter if any player gets a call or closes the app - the game continues for the others.
    But .. your game is basically done. It will be quite some work to convert.

    Fusion would be a good fit for shooters in general. Downside: In our experience, it's not great to run a host on a mobile client. It will be interrupted frequently during gameplay and this affects everyone. This will be the same for other solutions which use a Host/Server. Fusion helps you get Host Migration done but this technically never works without interruption.
    The "shared mode" for Fusion is better for mobile (it doesn't rely on a single host/server) but less good for fast paced games and there are likely more corrections. Check out the samples for Fusion. Reconciliation is explained here.

    Unless you'd refactor the game a lot (to ECS / Quantum), you will likely end up with a client hosting the game. This has some drawbacks, no matter the solution you pick.

    Happy coding :)