Search Unity

Multiple game rooms with one dedicated server process

Discussion in 'Multiplayer' started by DenisNP, Jul 28, 2017.

  1. DenisNP

    DenisNP

    Joined:
    Jul 28, 2017
    Posts:
    2
    Hello everyone.

    I want to create online 2D game with Unity. I have dedicated server running Ubuntu 16.04, and the clientside of the game will work in browsers using WebGL. I also prefer to use HLAPI and NetworkManager,NetworkIdentity etc because of simplicity.

    So my plan is to write very similar code for server/client and just run separated Unity process in headless mode on the server with no graphics to accept connections. I want to use Unity's physics engine to calculate entire game process on the serverside to avoid synchronization issues.

    I've already figured out how to make it work when single Unity process with one NetworkManager object for the server runs striclty one game room, where all players see each other and are located in one virtual space. I've also read about Unity Multiplayer Service's matchmaking.

    But how can I do something like separate game rooms with one server Unity process on my own machine? Can NetworkManager has instances linked to different game objects (e.g. maps) in one scene?
     
  2. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    Nothing like that is built in, but you can always implement it yourself ;)
     
  3. DenisNP

    DenisNP

    Joined:
    Jul 28, 2017
    Posts:
    2
    How can I do this? Should I switch to LLAPI ? So, if I can't use built in network identifications, network transform, auto spawn and other HLAPI functions, I would better write my own client-server communication with WebocketSharp :)

    But maybe I can get rid of it. It is very common use case — many players in different rooms with one server — isnt it?
     
  4. TwoTen

    TwoTen

    Joined:
    May 25, 2016
    Posts:
    1,168
    You can do it with HLAPI. There is no magic barrier preventing you to do certain things.
    The HLAPI is also Open Source. Check the NetworkManager sourcecode to get some insight.

    As for how to do things, that's your job as a developer to do design decisions. I can give advice or answer technical questions. But I wont develop your game ;)
     
  5. PauloEgidio

    PauloEgidio

    Joined:
    Jul 19, 2017
    Posts:
    12
    I did this. Using only hlapi and unet.
    Created my own gameroom objects.
    Not difficult, really.
    Used rebuildobservers to let only people in the same game room see the objects created.
    You have to use onaddobserver also, because net clients do not call rebuildobservers..
     
  6. DungDajHjep

    DungDajHjep

    Joined:
    Mar 25, 2015
    Posts:
    202
    how physically the rooms do not affect each other ?
    @DenisNP did you find your answer?