Search Unity

Type Room Name and JOIN

Discussion in 'Multiplayer' started by MadKadir, Mar 4, 2017.

  1. MadKadir

    MadKadir

    Joined:
    Mar 10, 2016
    Posts:
    2
    Hello All,

    I am not experienced in multiplayer so excuse me if I am not adept at the terminology.

    I am trying to develop a board-like game... a turn based card game. The players will all be at the same physical location (ex: school cafeteria) but use their device instead of cards, boards or checkers etc. The lobby structure should work like that:

    1. P1 creates a game (match request) by giving it a "game name" (or room name) and a password. He/she tells this name and the password to the friends verbally (since they are at the same location)

    2. P2,P3,...(max 10) etc. want to join the game created by P1 so they click "Join Game". A list of pending games appears with a scrollbar and searchbox... when the game created by P1 is selected password is prompted and after entering the password those players can join this private room..

    3. P1 clicks START GAME and the game commences for those players in the room...

    The game is a state machine where the state is changed by the players in turn. It does not require that much real time (like fps or rts games).

    Now, I've been looking for a backend service and considering GameSpark, Playfab, or Photon. Which one is more suitable for such a purpose explaied above? All? None? What kind of architecture should I build?

    Thank you,
    Any help, highly appreciated...
     
    Rodolfo-Rubens likes this.
  2. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    Something like this would really need a central dedicated server to both list the game names/passwords, and handle the interactions between players. You wouldn't for example, be able to just have players locally connect to each others devices wirelessly over IP. I could go into the details as to why if you wish, but ultimately the internals of how IP addresses and ports work would not only make this virtually impossible to do (if not entirely impossible), but it would question whether it's worth doing at all.

    So yeah, the only way I see something like this being possible is if you were to have a single dedicated server running an application that handles your server logic. So for example, it would:
    • hold a list of data for player game names/passwords
    • handle requests to play another player's game, by checking the name/password being sent and then adding the player to the game
    • handle incoming game-related requests being made by players in each game to form the incoming part of the logic
    • sending updates about the games to players within each game
    Effectively this means that players can play with others remotely, but you don't have to let them know this. If you don't expose the game name/password anywhere, then only people told the name/password will be able to get on the game so it would be down to how the host exposes this information.

    Hopefully this helps. Good luck!
     
  3. MadKadir

    MadKadir

    Joined:
    Mar 10, 2016
    Posts:
    2
    Hi donnysobbony,

    Thx for the reply...

    I was considering Firebase for this purpose, realtime database to hold the game room info and the players that are in the room and cloud messaging to handle the RPC of the game. However, the Firebase cloud messaging seems to have some problems with the unity enviornment... It just keeps telling unhandled firebase dependencies...

    I wonder whether GameSparks, PlayFab or Photon might be used for this purpose??
     
  4. donnysobonny

    donnysobonny

    Joined:
    Jan 24, 2013
    Posts:
    220
    Hmm, if you are keen to use firebase (I assume you maybe experience with it etc?) then it might be worth looking into the issue you're having with dependencies. This is normally caused due to you lacking certain runtime libraries (dll's for windows) within a "Plugins" folder in your unity project. We get these types of errors when working in unity due to unity's own project structure (and assembly code) being slightly different to the usual environment, and it's more likely firebase was built in to the usual environment. So to look into fixing it, the errors you are getting should inform you which dependencies are missing. You'll need to locate these files and place them within a "Plugins" folder within your unity project. If you need further help with this let me know.

    If you are keen to try different avenues however, here's a few options based on what you've mentioned already, and some additional ideas:
    • many of the options that you've mentioned (as talked about below) come with built-in services for matchmaking, where one peer creates a game, and other peers can connect to it. In this case a "game" can be identified by name, allowing other players to connect to a game by name.
    • matchmaking normally consists of two elements:
      1. a centralized server that holds records of players and games. Custom information can be held against players to be able to customize how players are automatically paired up (you probably don't need to worry about this) and information is stored against each game to both identify it, and determine whether players can join (based on maximum players etc)

      2. some sort of server infrastructure (may be client-server or peer-to-peer) to host "games" as players start playing together. Ultimately, each set of players will be in their own instance of your game, either hosted within some sort of cloud server (likely using the client-server model) or hosted on their own device (peer-to-peer, not recommended for handheld devices)
    • the services that you have mentioned (and more specifically than "Photon": all of photon's services except Photon Server and PUN) include matchmaking services using the client-server model (PUN relies on the peer-to-peer model). The idea is, you'll use some sort of runtime library in your code (imported into a Plugins folder or downloaded from the asset store) that will give you methods to create, list and join games. Creating a game will allow you to name the game (usually by string) and specify additional parameters such as maximum players etc. You will then be able to list games on other clients and use your "join" method to join a game by it's name. This means that there would be a little bit of code to do to get it all working, but you should be able to formulate any type of matchmaking setup with create/list/join functionality
    • unet also comes with a matchmaking services. Some have mentioned latency issues with unity's own third party services, however they are designed to be used directly with unet and therefore offer the best maintainability if you're building a multiplayer game in unity. I would definitely recommend trying this out for yourself. To use it, you have to first set up multiplayer services on your project, and then you can make use of the functionality shown here: https://docs.unity3d.com/560/Documentation/ScriptReference/Networking.Match.NetworkMatch.html
    • unfortunately, none of the above services support password protected matching (to my knowledge). So you have two options here, if you desperately want to password protect the joining of games:
      1. either you will need to code in an additional layer on top of your matchmaking code (where you're calling create/list/join) to expect the user to submit the game name and password and for you to check this against data that you have stored in your code. This would be pretty simple and definitely keeps everything scalable.

      2. or you would be better off implementing your own matchmaking service. This would definitely give you better control and potentially lower your overall costs but I don't recommend this unless you have good experience with networking etc.
    Hopefully this helps. Let me know if you have further questions.
     
  5. GameSparks_Clare

    GameSparks_Clare

    Joined:
    Feb 7, 2017
    Posts:
    37
    Hi Abananzer,

    You can achieve all of this quite easily with GameSparks. Our out of the box Challenge features should be able to do this for you. You can check out our guide on turn based challenges in our documentation here. If you run into any issues you can contact support who will be able to point you in the right direction and help you with any additional custom features.
     
  6. nik_ai

    nik_ai

    Joined:
    Jun 14, 2017
    Posts:
    9
    @Abanazer , for you requirements , Firebase Realtime Database is perfect, in short you can develop whole turn based multiplayer game with it. And the biggest advantage is "CHEAP COST".
    this is Web Client tutorial, you can check Firebase Realtime Database Unity Guide on official firebase site.