(Unity) Multiplayer

Discussion in 'TZT GameDev' started by Yogr, Jun 14, 2017.

  1. Yogr

    Yogr Meatball Sub Pro

    Post Count:
    1,214
    Working on creating a standalone Unity server solution to work with Amazon GameLift.

    I'll post here with my findings, in case anyone decides they want to do a dedicated server multiplayer game in Unity.

    Currently, Unity and Photon only offer P2P or pseudo-P2P solutions out of the box. Unity has had "Standalone Network Server" on their backlog for almost 2 years and it hasn't released yet, so I gotta go through some hoops.

    My initial impression is that Photon offers a pretty nice solution, with bit level compression, authoritative logic with some sort of "spoofed" peer, relay, matchmaking, etc. and they have some of the best pricing for their services.
    Photon, however, rents physical servers and shares hosting your game on those physical machines alongside other games, that's how they are able to offer such good rates. They don't offer the scalability and reliability of AWS.

    GameLift also hooks into other AWS services easily and uses the same credentials / identity pools, which makes authentication, db retrieval, server access, etc etc very secure and easy to set up and maintain. It is a little more expensive than Photon but you get what you pay for.
    The only downside to GameLift is figuring out how to run a dedicated server, because that's all they support right now. You have to provide them with a server binary that they can virtualize. And unfortunately, Unity hasn't delivered an out of the box standalone server deployment.

    So, I'm going to attempt to build a server binary that can authoritatively drive hundreds of game sessions per instance using Unity's network framework.
     
  2. Utumno

    Utumno Administrator Staff Member

    Post Count:
    43,504
    I'm a little surprised that something more generic doesn't already exist. There have to be fucktons of devs who want this functionality.
     
  3. Yogr

    Yogr Meatball Sub Pro

    Post Count:
    1,214
    There are a ton of developers that want this. According to my recent googling, anyway. And it's been on Unity's road map for years.

    To get your server to work with a Unity game and be authoritative, it needs to run UnityEngine. It needs to run essentially all the same code the clients will run, calculating collisions, physics, animations, etc. That way it can just take all the user input, figure out what the game is going to look like, and spit the result back as the source of truth.

    So you have to create a system that flags values that should be "owned" by the server, yet allow for underlying predictions by the client. And the server code must work for all 40 fucking platforms Unity supports. Simultaneously.

    Its basically rocket science.
     
  4. Utumno

    Utumno Administrator Staff Member

    Post Count:
    43,504
    Ah, now I see the difficulty.
     
  5. John Zee

    John Zee Good news everyone!

    Post Count:
    3,322
    Less posting in new threads, more finishing your game.
     
  6. Yogr

    Yogr Meatball Sub Pro

    Post Count:
    1,214
    IM WORKING ON IT

    - i got a 3 day weekend starting tonight. plan to get this thing up on GameLift and get some copies out to testers. Web player is dead though, I need Android people.
     
  7. Utumno

    Utumno Administrator Staff Member

    Post Count:
    43,504
  8. Yogr

    Yogr Meatball Sub Pro

    Post Count:
    1,214
    Yeeap. Unity with GameLift is a failure for now.

    For some reason Amazon's AWS for Unity SDK does NOT include support for GameLift CLIENT.

    GameLift Client for .NET requires a specific version of AWSSDK.Core.dll which conflicts with their AWS Unity SDK's AWSSDK.Core.dll dependency.

    So Cognito + GameLift can not be used together on the client in Unity with their current package builds.

    <-- super confused as to why that is.

    Sort of.

    Cognito is really a "Mobile" authentication service. If I were building a Steam/PC game in Unity and wanted to use GameLift it'd work fine.

    What's weird is the "UnityInitializer" class that comes with the AWSSDK for Unity and is required to be called to use ANY of those services (DynamoDB, S3, etc) is not included in the latest .NET GameLift SDK. So you wouldn't be able to use anything, not just Cognito.

    My guess as to why this is is that GameLift for Unity is a newer thing and they just haven't updated the AWS for Unity SDK with the latest AWSSDK.Core that GameLift client needs yet.

    I can't wait around for that day to come, so I'm ditching GameLift and moving forward with Unity Multiplayer services. Which, ironically, I can still use AWS Cognito with.

    TL;DR: Ditching GameLift, using Unity Multiplayer's psuedo-P2P services.
     
  9. Sear

    Sear TZT Neckbeard Lord

    Post Count:
    34,720
    You are a brave soldier for attempting this.

    Once upon a time I dreamt of developing a CCG, but my ambition could not get past the complexity of networking/mp code.

    Everything I've read about it basically amounts to "just use Photon", but even that didn't seem easy.
     
  10. Agrul

    Agrul TZT Neckbeard Lord

    Post Count:
    48,183
    agree w/ searyx

    photon seemed ok when i dicked around w/ it to set up the troll game multiplayer but as searyx said even it didnt seem easy

    i also have always been deterred by not wanting to learn networking & sockets & all that bullshit in any detail
     
  11. Utumno

    Utumno Administrator Staff Member

    Post Count:
    43,504
    fucking dev plebes ignoring ops stuff
     
  12. Yogr

    Yogr Meatball Sub Pro

    Post Count:
    1,214
    Haha. Yeah Photon was the bees-knees for a while.

    Recently Unity put out a huge update on their Multiplayer/Networking code and launched their own Multiplayer services.

    And since it's free, I'm rolling with that first.

    I have some concerns with packet overhead using Unity's native HLAPI, as I read that Photon does use Google's Protocol Buffers for bit-level compression. Unity's built in SyncVar, ClientRPC, Command, etc annotations look super fun and useful though. And I read that they use some relatively small byte hashing to store RPC messaging, so I am comfortable moving ahead with them for now.

    Once I implement the basic functionality I'll run through a dungeon with 4 clients connected and see what kind of data usage occurs. Then I'll try and optimize if I can by reducing SyncVars / calls, maybe try to make some more things deterministic on the client without sacrificing gameplay and see if that helps at all.

    If it seems reasonable I'll stick with Unity as I know they have more paid developers working on this and there will be more support for it than what Photon can put out moving forward. (Plus it's free)

    I'll keep this thread updated as I find out more.