Search Unity

Unity Networking Creating Rooms

Discussion in 'Multiplayer' started by Zero123, Nov 16, 2014.

  1. Zero123

    Zero123

    Joined:
    Aug 31, 2014
    Posts:
    23
    Hello Everyone,
    I am working on a networked game with unity and came across some trouble. I am trying to implement a match making system. I have already a game that lets multiple players connect to the main game. In my game we have mini games, i want to let each player put in a request to play a mini game with other players, so thus i need a match making system. When the player clicks play mini game, a request is sent to a php sql server which is using tables along with unique id's of each player to organize players into teams of 3, Now i have this part all done, so the logic for separating players is done.

    Now i want the sql server to send the unity network id's of the players in a single match back to the server. I think what i need to do is call an rpc on each of those network id's and have those players load into the same level by setting the level prefix to the same number. What i want to ask is this the right approach? does level prefix work like this? and would it be possible to use a foreach loop on the server to send rpcs to each of the players on the same match? I just want these players to appear in the same game. I have access to their unity network id's and unique id's which i assign myself.


    I know this problem sounds a bit complex, i hope someone can help me or give me some advise. I feel ike i am close but i am missing a few steps. Any help is appreciated.

    regards
     
  2. sandolkakos

    sandolkakos

    Joined:
    Jun 3, 2009
    Posts:
    285
    I think that using the built-in Network API, the creation of Rooms is not possible. I was trying do this yesterday and I didn't managed to do it.

    The why I think it is not possible is because when you Register the First Host, you do it like this:

    Code (csharp):
    1. Network.InitializeServer(MAX_CONNECTIONS, 25000, !Network.HavePublicAddress());
    2. MasterServer.RegisterHost(GAME_TYPE_NAME, GAME_NAME);
    Where the GAME_NAME is the RoomName. And now, each new Room only can be registered by the Player that had Initialized the Server.

    Please, somebody correct me if I am wrong.
     
  3. Zero123

    Zero123

    Joined:
    Aug 31, 2014
    Posts:
    23
    I think a athorative server approach will be better for this. If we a main server as the central hub, then i think i should be able to send the unity id's from the sql database using php to the server, which can then call the load level function on those specific id's by sending them an rpc. now the question is, is this the right approach? or does someone else have a better solution?