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?
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
).
Yes, that is exactly what I want. I just need the ability to connect to whatever backend network solution. Thank you so much!