Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question [MLAPI] Simultaneous work as a server and as a client.

Discussion in 'Multiplayer' started by Balphagore, Nov 4, 2021.

  1. Balphagore


    Jul 18, 2019
    Is it possible to make the project in one instance the client, and in the other the server? For example, there is a master server, game servers, and regular clients. So the game server will be a client for the master server and a server for regular clients. Didn't find a way to implement this, since NetworkManager is a singleton and cannot be in two states at the same time.

    If you edit the NetworkManager code and remove its declaration as a singleton, then technically it is possible to run two NetworkManagers in different states, but then other package files start giving errors, since they access NetworkManager through its singleton, which is no longer in such a situation.

    Is there any option to implement this? The idea is for the master server to act as a hub, to which both clients and game servers connect to find each other, and then connect directly. Is it possible to implement this now using only MLAPI? Or do i need to use another solution?
  2. DiegoSynth


    May 12, 2019
    Nobody answers in this forum or in any Unity group. The community seems to be super cool... maybe they are in a freezer.

    I'm also trying to start with multiplayer, asked about separated client and server and obviously got no reply.
    From what I've seen, MLAPI (now NetCode) would be really limiting me regarding the way I'd like to structure things. You basically have to make remote calls among others, and adapt yourself to the genius decisions they've taken arbitrarily which totally block the way (like the singleton you mention).

    To make it short, I found that you can also use Unity Transport, which is a lower level layer (I guess NetCode is written on top of that). With that API you can basically handle client server connections as a normal human being and decent designer + programmer.
    I suggest you take a look at it:

    Workflow: Creating a minimal client and server | Unity Transport | 0.3.1-preview.4 (

    (beware, if you copy paste the server / client code, the IDE (Visual Studio in my case) will throw errors as they wrote a line of code wrongly (the call to BeginSend). If you need help with that, let me know.

    So I hope you find this useful!