Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Unity Transport for a Unity-less server

Discussion in 'Entity Component System' started by YurySedyakin, Sep 24, 2020.

  1. YurySedyakin

    YurySedyakin

    Joined:
    Jul 25, 2018
    Posts:
    61
    As I understand, right now Unity transport can't be used to connect to a unity-less server. Is there a plan to enable this? I have to stick to LiteNetLib until then...
     
  2. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    147
    The new Unity transport uses UDP sockets, you can use whatever network library you want as server as long as its UDP and you implement the same network protocol on top of that.

    Plus you can even switch out NetworkInterfaces in the Unity Transport package, which means you can implement an INetworkInterface which uses LiteNetLib. Then you create your driver like this m_Driver = new NetworkDriver(new TestNetworkInterface()); and unity will also use LiteNetLib if you want to use it for the client and server.
     
  3. YurySedyakin

    YurySedyakin

    Joined:
    Jul 25, 2018
    Posts:
    61
    Well, that's the whole point of it. There is a lot of stuff in Unity transport implemented on top of UDP sockets, namely the protocol itself, connection state machine, the pipelines (compression, sequencing, etc...). I'm interested in having all of that in a unity client but also connect to a unity-less server.
     
  4. FakeByte

    FakeByte

    Joined:
    Dec 8, 2015
    Posts:
    147
    Then take a look at the UdpCHeader struct, its a 4 byte struct that contains the header, then just add your data behind the header, should be pretty simple as long as you don't use pipelines.
    If your network library is doing something like packet fragmentation etc. then you need to implement your own INetworkInterface to handle this or just copy the BaselibNetworkInterface and add support for that, or you deactivate such functionality on the server network library.