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.

Unity Multiplayer Spawning a server instance programmatically without a client.

Discussion in 'Multiplayer' started by Christian-Tucker, Jul 23, 2018.

  1. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    I have a small game project that I am wanting to port to Unity, I've spent time learning UNET and understand how most of it works, however I'm trying to figure out how to do one thing specific.

    In the scope of my project there's two servers. I have the "Master Server" which is a server that I've already made which keeps track of things like user accounts, user currencies, friends, lobby-based chats, etc. Then there's the "Game Server" which would be the Unity's headless server instance.

    I'd like the "Master Server" to be in charge of starting the "Game Server". When a set number of players have all queued up for a game, the "Master Server" should create a new "Game Server" instance and tell the players about the connection details. From there the players will connect to the "Game Server" and play the game.

    Here's a quick graph of how I'd like this to work:

    Code (CSharp):
    1.  
    2. Master Server   --->   Game Server
    3.      ^---------Player---------^
    4.  

    If you need a game in mind to visualize this, think something like DoTA or League of Legends where each individual game is actually hosted on a different server / port. When players queue up for the game, and enough players are found, a game instance is created and the players establish a connection to the game server.

    I'm just trying to find out how to spawn a Game Server instance via Code, without a currently active Unity Instance.

    My server is written in NodeJS, but I can port it to C# if `required` but I would prefer to stick with `NodeJS` as there's already hundreds of hours into it.
     
  2. proepkess

    proepkess

    Joined:
    Dec 26, 2016
    Posts:
    11
  3. Christian-Tucker

    Christian-Tucker

    Joined:
    Aug 18, 2013
    Posts:
    376
    Thanks for your reply, I've gone over the original and also the standalone links vaguely and I think there may have been a miss-understanding. The first link won't work, because I'm not using Unity for my master server. I also already have a master server created and functional. This game was originally, I'm just porting it over to Unity.

    I just need to know how to create a Unity Server Instance via code, outside of Unity, as my server is NOT written in C# and cannot be compiled from within Unity. For example, starting an executable with parameters.

    server.exe --map 3 --mode deathmatch --weather disabled --port 8080


    as an example, which would start this instance on port 8080 using map 3, no weather, and the mode set to deathmatch.

    This is obviously just for example purposes, but something similar to this would be lovely.
     
  4. sawirricardo

    sawirricardo

    Joined:
    Apr 2, 2020
    Posts:
    1
    Hi, @Christian-Tucker , how did you manage to do that? I would love to know what steps did you take in the end