Search Unity

Which networking solution is right for me?

Discussion in 'Multiplayer' started by 511, Apr 27, 2015.

  1. 511

    511

    Joined:
    Nov 18, 2012
    Posts:
    55
    Originally I started my project in Ue4 but the compiles times are killing me and I don't want maintain my own language bindings.

    I am not sure how my game will turn out but it will me some sort of coop game with a medium sized map ,less than 20 players and as much AI as is feasible. I also want the usual authoritative server model and it would be nice if the the programming is "streamlined". For example in unreal I just have to press play and it starts the server and connects everyone instantly.
    But I think that could be easily automated in Unity with custom scripting anyway?

    There are so many networking solutions right now. I think my best bet would be UNET in 5.1 but the beta requires pro. I don't think it is possible to just subscribe for 1 month?

    Then there is Bolt which looks great but is still in beta, costs $80 and is only maintained by a single person.

    Any recommendations?
     
  2. PrimeTales

    PrimeTales

    Joined:
    Jan 17, 2015
    Posts:
    9
  3. 511

    511

    Joined:
    Nov 18, 2012
    Posts:
    55
    I don't think unity built in networking is authoritative and photons site is flooded with marketing and the examples don't work with Unity 5 yet(at least not out of the box).

    Maybe photon could be an option though.
     
  4. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    What kind of game are you building?

    Photon isn't authoritative if you run it in the cloud but if you run your own server it is, nevertheless I don't recall much documentation for it (when I tried it I never managed to do anything with it :/ )

    Unity networking (RakNet) can be made to be authoritative actually, but you need to run a unity instance (probably headless) as your server and implement everything from there up.

    UNET (I think) will work as an authoritative server if you can wait a short while (There's a 30 day trial with pro but I don't know that that includes the beta) and it's looking like it's going to be a really good networking solution in general.

    Another that might suit your game <slightly shameless plug> is DarkRift, it should handle your game fairly easily and I try and maintain the documentation for plugins!

    If you want a run down on all of them then there's a good comparison here.

    Jamie :)
     
  5. PrimeTales

    PrimeTales

    Joined:
    Jan 17, 2015
    Posts:
    9
    Or you write your own network communication with a network framework like lidgren
     
  6. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    Oooo, I noticed you mentioned you need as many AI as feasible. Does that mean you're making some sort of multiplayer zombie-shooter game like COD Nazi Zombies? Anyways, AI will generally have to be networked just like player characters in a traditional setup: simulate data on 1 client/1 server/shared and distribute the resulting data. This unfortunately creates a lot of bandwidth overhead so 20 players and an additional 20 AI will cause issues. Discounting message header overhead: 40 (# of characters) * 12B (position data size) * 10syncs/second * 20 (amount of players to distribute to) = 96KB/s load on the server. Then there's messages for shooting and syncing HP. Finally, add in the 40B header and you get about 500KB/s bandwidth cost for hosting 1 game. You'll end up with huge server -$$$ and potentially laggy games.

    That's why COD doesn't use the traditional method. Actually, it uses the new traditional networking method which is lockstep. Lockstep is basically sending input (in a very broad sense) instead of output. It's based on the concept that telling a unit to move forward is a lot less expensive than constantly sending positions. Here <slightly shameless plug> is an implementation of lockstep for my RTS game: http://forum.unity3d.com/threads/dphysics-and-lockstep-framework-demonstration.318829/ - Powered by DarkRift ^^.

    FPS games can do something very similar. For example, rotations you would have to sync every synchronous frame but when shooting, you could just send a small blip that tells everyone your character fired, and everyone would fire based on the synced rotation. To move forward, you would send a small blip to move forward and everyone would move you forward based on your rotation. Even if there's a joystick involved with different levels of axis, you can just send a byte representing the degree to move at.

    The beauty of lockstep is that you only need to sync information everyone doesn't have - which means AI don't need to be synced because their actions are the direct results of player actions, and player actions are the same for everyone since they're synced.

    Btw, a little trick: 3D rotations can be represented pretty accurately with 6 bytes.
     
    Last edited: Apr 28, 2015
  7. PrimeTales

    PrimeTales

    Joined:
    Jan 17, 2015
    Posts:
    9
    From time to time you should send the position to compensate lost packages.
     
  8. jpthek9

    jpthek9

    Joined:
    Nov 28, 2013
    Posts:
    944
    For a synchronous simulation? If you lose 1 package and continue running the simulation, the entire game will be desynced and the only way to sync it up is to send everything including position, rotation, health, and even the existence of units, because everyone's input would be different (imagine if that lost package was an attack command and the target dies due to the command). That's why game likes Starcraft have to pause the game when the frame's packet hasn't arrived yet.

    The game would be better off just ending.
     
  9. BFGames

    BFGames

    Joined:
    Oct 2, 2012
    Posts:
    1,543
    With lots of AI a lockstep model would be pretty neat.

    In regards to network packages. Then Unity's old network could work, UNET could work, Photon (server, not cloud), Bolt, DarkRift and so on could all work. Whats the best solution? Depends on your game, ambitions and skill set really.
     
    jpthek9 likes this.