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] Which networking solution would you recommand ?

Discussion in 'Multiplayer' started by RayanKheloufi, May 28, 2018.

  1. RayanKheloufi

    RayanKheloufi

    Joined:
    Apr 27, 2018
    Posts:
    10
    Hello, people!

    I spent a few weeks creating a small prototype of a 2D game (sidescrolling), with a player, some weapons, bullets. The main idea is to have one map playable by at least 20 people, 50 or more if possible! Like you connect, you wait for 20 others to come and the game starts. The game would be playable on a phone (Android).
    I would like to implement the network part of it before going any further.
    I'd be willing to give some money for it!

    Here are my two questions:

    1) Which solution should I follow :
    - One player is also a server and the others sending and receiving packets to and from him/her
    - One server sending and receiving packets to everyone.
    The first solution is costless, but can a computer or an android phone actually manage to make this kind of computation for 20/50 players? (for how many players in the same room can this solution apply ?)
    The second would be more expensive I know, but also more efficient. I'm willing to give some money for it. Do you know on average how much it would cost?

    2) Which networking solution should I use? I've started some tutorials on Photon, but it seems a bit limited for my wallet for now ^^'
    I've heard about Forge and DarkRift, and they seem to have good reviews. What do you think about them? And could Unity Multiplayer handle this kind of project?

    Thank a lot!
     
    Last edited: May 28, 2018
  2. thegreatzebadiah

    thegreatzebadiah

    Joined:
    Nov 22, 2012
    Posts:
    836
    I'm not super experienced but since no one else is chiming in I'll add my two cents.

    1) If you're aiming for that many players on mobile you may have no choice but to go with a dedicated host more because of cpu issues than networking issues. This may no be an issue though if you don't use a lot of physics. If you do use a lot of physics it's going to be tough for the the host client to handle all the processing so you'd be better off doing it on a dedicated server with clients being as "dumb" as possible and just handling input and displaying the character wherever the server says it should be. If you're not doing a ton of physics then I would go with peer-to-peer with one of the peers being the host because of the costs that you mentioned.

    Costs are going to depend entirely on how much bandwidth your game uses. You can check bandwidth costs on AWS and do a bit of math to get an estimate. It's going to be almost meaningless though until you've done a thorough pass optimizing your game for bandwidth usage.

    2) Personally I would use UNET but that's more or less a matter of personal preference. Any decent networking system is going to be pretty much equally as capable for most games (read: not mmo).

    P.S. If you want to reduce your bandwidth usage you may want to look in to my Smooth Sync plugin. It is especially effective at reducing bandwidth used in 2d games, and it will make syncing your networked objects dead simple.
     
  3. RayanKheloufi

    RayanKheloufi

    Joined:
    Apr 27, 2018
    Posts:
    10
    First of all, thanks a lot for your answer!
    I checked your plugin and I'll definitively use it when I'll have to think about the bandwidth.

    1) The only 'expensive' physics to calculate is the player's one. The code checks whether he is on the ground, falling, on a wall etc, and adapt its behavior according to these elements.
    So if I understand, you would rather recommend to do these computations on a server and to send the client's position to the client's device, who will handle the rendering?

    2) alright I'm gonna start following tutorials on UNET !
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    20 to 50 people in a match while hosted on a mobile device is probably a pretty big ask, unless the game was extremely simple. Also you need to expect periodic communication issues when hosting with a mobile device (they may be a passenger in a car moving between towers, going through a tunnel, hit a dead zone temporarily, etc). For those reasons I'd also suggest using a dedicated server structure instead of having hosting on one of the mobile devices as well.

    As far as costs, you'd be paying for your server at whatever rate the server provider charges, but you wouldn't need to pay for cloud networking services such as Photon or Unity Multiplayer since the clients can directly connect to your server. So it is probably a cost savings (since generally server providers charge significantly less for bandwidth).
     
  5. RayanKheloufi

    RayanKheloufi

    Joined:
    Apr 27, 2018
    Posts:
    10
    Alright, I'll definitively use a dedicated server then.

    The thing is, games like Fortnite of PUBG have been launched on phones, and they are big 3D games with a lot of weapons, objects and stuff. If they can support 100 players in the same room, I was hoping that 20 to 50 players on a way smaller 2D game would be feasible. Maybe starting with 20 players should be a very good start then

    Thank you
     
  6. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    I've played the phone version of PUBG, and most of the "players" in each match are bots, with a few real players sprinkled in (was less impressed that I almost always get chicken dinner when I realized why). Also I haven't seen anything to indicate that they are actually hosting the game on one of the player's phones.
     
  7. RayanKheloufi

    RayanKheloufi

    Joined:
    Apr 27, 2018
    Posts:
    10
    Oh wow, I didn't know that...
    Well, I played with a phone players at Fortnite, and we had the same players against each other so, at least I know that's possible ^^'

    Yeah I'm sure it's not hosted on one of the player's phone. It definitively is a server.

    Anyway, I got my answers, thank you very much guys !