Search Unity

Super simple multiplayer that works only with input

Discussion in 'Multiplayer' started by TimNick151297, May 21, 2021.

  1. TimNick151297

    TimNick151297

    Joined:
    Apr 21, 2013
    Posts:
    21
    Hi there,

    I'm currently trying to achieve a simple synchronization for my scene. It is a single scene and it only runs in 2D space, so only the player inputs would have to be synced. How and where would I start with that? I have pretty much no multiplayer experience so far.

    Thanks for your help!

    Cheers Tim
     
  2. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168
    TimNick151297 likes this.
  3. TimNick151297

    TimNick151297

    Joined:
    Apr 21, 2013
    Posts:
    21
    Thanks for your answer! Is there some easy way to set this up in Unity? I‘ve read something about some multiplayer systems, but I‘m not sure which one would fit my requirements best.
    Regarding Input Data, is this some special class that you can directly access or how would I create that?

    Thanks again!

    Cheers Tim
     
  4. ep1s0de

    ep1s0de

    Joined:
    Dec 24, 2015
    Posts:
    168

    In my opinion for your tasks LiteNetLib (https://github.com/RevenantX/LiteNetLib) and hand-written ("if you want to do better, do it yourself"), the first has basic functionality for interaction between connections, the second you can write yourself using UDP or TCP

    Read carefully, everything is explained in detail, the main thing is to understand how to implement it
    https://www.gabrielgambetta.com/client-server-game-architecture.html
     
    TimNick151297 likes this.
  5. TimNick151297

    TimNick151297

    Joined:
    Apr 21, 2013
    Posts:
    21
    Thanks, I‘ll give it a shot!
     
  6. LaneFox

    LaneFox

    Joined:
    Jun 29, 2011
    Posts:
    7,536
    Rolling your own is really involved. You're best off using an existing system for both transport and high level. Unity worked on UNET but deprecated it a while back. The best solution really depends on your project requirements but Mirror and PUN are the most common solutions right now with lots of games using them.

    I personally recommend Mirror. They have existing structures for syncing transform data and such, but you can roll your own messages and serialize/deserialize whatever data you want manually without having to worry about the low end. This makes it pretty straightforward to send and digest input.

    The thing is though, if you're only syncing input you're going to run into a lot more issues than you think. Input-only means determinism if you want accuracy and a lot of interpolation/lag compensation for client comfort.

    Here are some useful references:


    Overwatch Gameplay Architecture -

     
    Cranom likes this.