Best practice for integrating network logic in Unity

Hello,

I have made a small prototype that use the C# TcpClient to connect to a remote server.
I am basically using the non blocking api to do the work, i.e. BeginConnect, BeginWrite, etc…
The responsibility of handling the network part is done in a MonoBehaviour attached to an Empty GameObject.
In the MonoBehavior I use a Coroutine to run the send/receive loop.

The information received from the server sets the model to dirty and the main thread can then render properly.

So far it works well.

I was wondering if this is the right approach for a full fledge application.

Anyone care to share their experience/best practices?

Thank you

Yes and no :slight_smile: You are correct UDP is faster. However we don’t have time to add our own layer on top of UDP to have some reliability and ordering.