Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved NetCode Transports

Discussion in 'DOTS Dev Blitz Day 2022 - Q&A' started by aetharra, Dec 7, 2022.

  1. aetharra

    aetharra

    Joined:
    Oct 10, 2021
    Posts:
    7
    If I want to use a different transport from Unity's, what is needed to be included and understood about a transport to make it compatible with NetCode for Entites?
     
  2. simon-lemay-unity

    simon-lemay-unity

    Unity Technologies

    Joined:
    Jul 19, 2021
    Posts:
    441
    Netcode for Entities is deeply integrated with the Unity Transport package (UTP), so unfortunately the transport package itself is pretty much unavoidable. However, UTP offers a mechanism to change its low-level network code, which could be used to provide an integration with a different transport.

    The mechanism is to provide a custom
    INetworkInterface
    to the
    NetworkDriver
    on creation. Network interfaces are responsible for the low-level network operations of sending and receiving data. In UTP 2.0 (which is what Netcode for Entities 1.0 depends on), the API is relatively simple. You basically provide a job to send data, which takes a list of packets as a parameter, and another job to receive data, which will fill a list with newly-received packets.

    So to answer your question more precisely, for a transport to be compatible with Netcode for Entities, it must be possible to make it work with the Unity job system. It doesn't need to be compatible with Burst, however (network interfaces can be managed objects).

    Unfortunately, we don't have any documentation currently about writing custom network interfaces. We're planning to write something, but at the moment your best bet is to look at the implementation. The relevant code would be in the
    com.unity.transport
    package. UTP already provides three implementations of
    INetworkInterface
    : one for intra-process communications (
    IPCNetworkInterface
    ), one for UDP sockets (
    UDPNetworkInterface
    , the default), and one for WebSockets (
    WebSocketNetworkInterface
    ).
     
    aetharra likes this.
  3. aetharra

    aetharra

    Joined:
    Oct 10, 2021
    Posts:
    7
    Yes, that is exactly what I want. I just need the ability to connect to whatever backend network solution. Thank you so much!