Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Question Choice of multiplayer solution for my project

Discussion in 'Multiplayer' started by Azumikkel, Mar 11, 2024.

  1. Azumikkel

    Azumikkel

    Joined:
    Apr 5, 2018
    Posts:
    4
    I have a 2d multiplayer game with a lot of rigidbodies and collision interactions between players as well as objects. The game is finished and works great as a couch multiplayer game, but I want to implement online multiplayer, and I need to choose an Unity multiplayer solution for that.

    Clip:
    https://imgur.com/a/oryaS54

    Players move using physics, they can bump into and push each other, pick up weapon objects, and there may be a large amount of rigidbody bullet objects active at the same time (could be limited through code if necessary).

    • I need the solution to support a peer to peer setup with a host player, and be able to connect clients through Steamworks.
    • A client should be able to have network ownership of their character's rigidbodies (so that there's no client-side lag when moving)
    • Ownership of weapons/objects should be transferrable between clients (so that weapon objects can be picked up by players)
    • Needs to have support for nested prefabs (I have 150 level prefabs, many with rigidbody objects inside that I need to be networked).
    • Needs to be fairly noob friendly, good documentation, well-tested, and free.
    Any suggestions on which solution to use from someone with experience would be welcome.
     
  2. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    6,567
    All of your requirements are covered by ANY network tech stack. These don't narrow down your choice at all.

    Documentation and tutorial wise Netcode for GameObjects has an advantage.

    That is going to be a gelatinous problem.
    Interactive networked physics is like the holy grail of multiplayer networking. This requires a high amount of technical prowess and networking experience to get the "player can push each other" part right. Fish-Net is the only solution that has the necessary client-side physics simulation (or prediction) available at the moment.

    Also keep in mind that adding online multiplayer to an existing game is far from straightforward, more so for a physics-based game. Effectively you'll be reimplementing the game with networking technology, not just adding a few things here and there.
     
  3. Kakr-98

    Kakr-98

    Joined:
    Apr 29, 2020
    Posts:
    53
    This is not true at all. Netick and Fusion offer that ability.

    However, predicting PhysX is unrealistic and should be avoided if possible. The integration, at least, used by Unity does not perform well for executing multiple steps together. With high ping, we are talking about more than 10ms (on an avg CPU, depending on the tickrate) solely consumed by calling `Simulate`. That's unacceptable.

    Many people only test locally and think that it's viable to predict PhysX, but in reality, it's something that must be avoided if possible. However, we still offer that option as it can work for some simple physics-focused games. Or games with very low tickrate. But that's about it.
     
    CodeSmile likes this.
  4. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    411
    There are a few solutions which support what you ask for, FishNet is the only FREE one that is proven through time and releases.
     
  5. Azumikkel

    Azumikkel

    Joined:
    Apr 5, 2018
    Posts:
    4
    Thank you for your thoughtful response. I've tried FishNet before and got completely lost trying to implement the CSP, but I'll give it a go again, and just accept the fact that players touching each other when playing online will turn out a bit.. fishy. Some wonky online multiplayer is probably better than nothing. Cheers
     
    Welfarecheck likes this.
  6. Duck_With_Grape

    Duck_With_Grape

    Joined:
    Sep 6, 2021
    Posts:
    30
    Multiplayer Game Devlopment is going to almost certainly be harder than you think it is, if you have not tried it before. My personal experience with multiplayer development started in a way similar to yours, trying to turn a local multiplayer 2D game into a online multiplayer one. I had been making games pretty solidly (as a hobbyist) for around 2 years at that point of time, and after months of trying to convert my 2D game from singleplayer to multiplayer, I was forced to leave it entirely and just move on. I did learn it, (and it looks like you are more skilled by far than I was starting to learn multiplayer) but I highly suggest anyone thinking about learning multiplayer to understand that, while multiplayer game development is not impossible to learn by any means, you have to essentially relearn a lot of things from the ground up. If you made some good singleplayer games already, and understand intermediate level programing principles, you can do it, its just that, especially for your first few attempts, multiplayer will be the biggest challenge you face in your game, by far.

    As for the question, I use Mirror, which was beginner-friendly enough (and I am told is close enough to the Network for Game Objects to allow you to switch between the two reasonably easy once you learn one), but network objects have a pretty limited child count, and nested network objects is a no-go, so I don't think it will work for your game. Overall, you may have quite a hard time getting rigid bodies and physics in general to work with your game, so I might recommend you making a MVP of your game (a new project with nothing more than simplified versions of your core gameplay mechanics) in multiplayer to get a good feel for things before trying to essentially change out the core framework of your current game.
     
  7. Punfish

    Punfish

    Joined:
    Dec 7, 2014
    Posts:
    411
    We have another release coming today (4.1.3) which resolves a lot of that 'wonky' stuff. P2 is still in experimental but you can expect it out of experimental in a couple releases!