Search Unity

Authoritative server running multiple scenes

Discussion in 'Multiplayer' started by SleepyB1, Oct 3, 2019.

  1. SleepyB1

    SleepyB1

    Joined:
    May 17, 2017
    Posts:
    2
    Hi, I want to develop a 2d multiplayer game using an authoritative dedicated server where each session contains up to 4 players and I thought of multiple ways to develop this and I can't decide what's best for my case.

    I would like to run multiple scenes on the same server, In unity it can be done using headless mode but is it suitable in production mode? (It will result in a lot of overhead). I saw some tricks to get it done like placing a scene inside another scene at different coordinates but it seems to tricky and problematic.

    Because of this I thought maybe I should use a custom/other physics engine (like bullet) and simulate each scene in the same scene at the server which sounds like alot of work that maybe is not needed in my case.

    Overall I need to sync players location and if they are jumping or colliding with each other, no shooting mechanics or something like that, I already developed 2d multiplayer shooter using PUN2 and understood it doesn't fit my new game, I also read a lot about the subject but I have a hard time deciding what fits my game.

    Another possibility is to drop the authorative part and make one client the "master" in terms of physics, but I think it will hurt the gameplay since all other players must wait till this client updates the server(and if te latency is high/lag spikes it will be bad).

    Any suggestion will be well appreciated, thanks a lot!
     
    Last edited: Oct 3, 2019
  2. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    Why would multiple scenes cause overhead? You mean in terms of size of the Unity server? or something else?
    Also you mentioned using PUN2. How does that fit with the dedicated server?
     
  3. SleepyB1

    SleepyB1

    Joined:
    May 17, 2017
    Posts:
    2
    I thought maybe running multiple processes instead of running a single process is an overhead since windows/linux does a lot of work when opening and switching between processes, perhaps Its completely irrelevant here.
    I meant I developed another game using PUN2 and understood it doesn't fit my new game, sorry for the misunderstanding and thanks for your response :)
     
  4. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    The main overhead from running multiple headless builds on the same server from my experience is each instance is loading a lot of the same assets into memory. So you're basically wasting memory with that approach. It depends on your game if that is a problem or not, as well as the specs of the server(s) you're renting.

    It is a non-issue for my game for example, because as I increase the number of instances on a server I'll run out of CPU resources before I run out of memory.
     
    MrsPiggy likes this.
  5. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    I see what you mean. I am not too familiar with running Unity headless instances on the server side and I am also curious how folks deal with this kind of builds.
    As @Joe-Censored said memory is likely a concern because you're running multiple Unity engines at the same time, duplicating all the assets. I don't know about CPU though. I guess it depends on what the game does, how much physics and collision detections it runs etc.
    This sounds like one of those problems that is best solved in the cloud by running small, short-lived servers for each Unity engine.