question

Vladislav Rashkov avatar image
Vladislav Rashkov asked

How to create 3 player game multiplayer matchmaking

1. Game has 3 player slots everyone plays for himself

2. In order to start to play, you search for a game like matchmaking and if 2 other people are searching it will create a game between you 3

  1. My current setup is:
  • DB Server - it's database that i am hosting myself that holds the main info of a user and of the game mechanics that I want to get from during the (3 player) multiplayer games.
  • PlayFab - hold the user accounts (that's all for now but will add more stuff in the future)
  • Unity - The game

I am new to Multiplayer and Playfab, from what I saw is that i have to put a (Unity Server) inside (Playfab multiplayer functionallity). When I do so I will have 1 more component so everything will be: DB Server, PlayFab, Unity Game, PlayFab/Unity Server

It's turn-based game so I imagine based on the above components It should work something like this:

  • Unity Game (Player 1) -> PlayFab/Unity Server -> calls the DB Server API -> PlayFab/Unity Server retrieves and works with the DB Server API data -> (Player 2,3)

The idea is that I want to use this as dedicated server that gets info from the main DB Server and then returns to users. Not sure if it makes sense but everything should be connected to the main DB Server.

    3. Another thing is that I want when a player leaves or disconnects to be replaced with a (BOT/AI) that will take his place until he returns. I think this code should be placed in the Playfab/Unity server to make most sense, but maybe I am wrong. And if that's the case how should I set it up, so when a user leaves AI takes his place and vice versa?

    4. Another thing I don't understand is if this is dedicated server + matchmaking how do I separate all the data. Let's say we have 30 users so this should be 10 matches in total for 3 players in a match. So if all our player data goes into 1 server how does the server knows where to return the data to?

    I am new to multiplayer and just want to understand how things should work. I looked also into Photon but i think that solution is a bit expesive atm so I was thinking if PlayFab server could do the job for me. I would be grateful if someone can provide pointers to my questions.

    Thank you!

    multiplayerMatchmaking
    10 |1200

    Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

    Seth Du avatar image
    Seth Du answered
    • I don’t think an external DB Server is required in your scenario. Any game mechanics or main info of a user can be stored either on the server build or PlayFab. Only when there are concurrent writes from multiple players, is the queued DB server required. Based on the description. The game mechanism can be stored in Title Data, because it doesn’t change frequently. You may simply call server API to retrieve data.
    • PlayFab matchmaking system work seamlessly with Multiplayer server 2.0, where you may enable auto-allocation for servers. It means that after player 1 and player 2 create a matchmaking tickets and matched, a server instance will become active, then each player can call GetMatch API to get the IP and port for connection. Matchmaking - PlayFab | Microsoft Docs
    • Bot/AI is something can be implemented in the Server build. It is reasonable to keep monitoring the connections in a multiplayer match.
    • The Multiplayer server is hosted with Docker. Each game is independent on data. “have 30 users so this should be 10 matches in total for 3 players in a match” à when you configure the server build, you will need to set up Standy server number and max server number. Those number can be customized based on your real requirement, but you may need to apply for increasing quota as the free quota for testing is limit. I suggest you to look into the document -- Servers - PlayFab | Microsoft Docs. We provide very detailed explanations about these features. Please tell me if you have any other questions.
    4 comments
    10 |1200

    Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

    Vladislav Rashkov avatar image Vladislav Rashkov commented ·

    Thank you for the asnwer.

    1. That's how I want to use it yes, just the DB Server to be for retrieving data and at the end of the game to save "END data" in it. The other time I will use PlayFab, so from what I saw "Shared Group Data" is the best option I have there?

    0 Likes 0 ·
    Seth Du avatar image Seth Du ♦ Vladislav Rashkov commented ·

    Shared Group Data is able to store the data you want, but to be clear, as long as "END data" doesn't contain files with large size like replay videos, and only contains some statistics, you may also consider storing in Player Read-Only Data separately for each player. Using Shared Group Data may be not convenient for later reference as you need to store the names of Shared Groups somewhere. There is no API that can list all the shared groups that a player has joined.

    Shared group is used to store temporary data like chat logs. Since you are already using hosted server, temporary data can be stored in the running server build.

    0 Likes 0 ·
    Vladislav Rashkov avatar image Vladislav Rashkov commented ·

    2. The game is not a big one, it's just a turn based board game, so there are not many "actions" that one player can make and one game will be between 5-10 minutes. As there won't be many users active at the same time I want to create a mechanic that if you are "queue-ing" for 20 seconds for example and don't find a match to automatically start a game against 2 bots, so based on the logic that for every game there will be a separate server I just don't seem to find that efficient. If we have 100 players playing against 100 bots, this will be 100 servers. So what I want to ask is, is it okay if there is 1 server which will just return data based on the "Shared Group Data" for example. So even if 100 players are playing on 1 server they are getting different data back. Or If that's not possible I guess my other option is to create "BOT" system for client and "BOT" for server side, because you should be able to play against bots by urself and against BOT when someone leaves/disconnects a game.

    Sorry if some stuff don't make much sense or are not correct, just trying to figure out how things work.

    0 Likes 0 ·
    Seth Du avatar image Seth Du ♦ Vladislav Rashkov commented ·

    2. You may also consider if it is necessary to implement hosted server. You may refer to Example: Turn-based multiplayer Async games. Shared Group Data can be used without hosted server.

    3. Playing with Bots -> When AI scripts are implemented in the client side, you should consider anti-cheating. There is no hosted server that can ensure the validity of the match process. Hence, Multiplayer servers are required. You are able to host multiple connection within one server instance, but will require help from external tools, some developers in the community uses SignalR to handle the connections.

    0 Likes 0 ·
    Vladislav Rashkov avatar image
    Vladislav Rashkov answered

    Thank you for the asnwer.

    1. That's how I want to use it yes, just the DB Server to be for retrieving data and at the end of the game to save "END data" in it. The other time I will use PlayFab, so from what I saw "Shared Group Data" is the best option I have there?

    2. The game is not a big one, it's just a turn based board game, so there are not many "actions" that one player can make and one game will be between 5-10 minutes. As there won't be many users active at the same time I want to create a mechanic that if you are "queue-ing" for 20 seconds for example and don't find a match to automatically start a game against 2 bots, so based on the logic that for every game there will be a separate server I just don't seem to find that efficient. If we have 100 players playing against 100 bots, this will be 100 servers. So what I want to ask is, is it okay if there is 1 server which will just return data based on the "Shared Group Data" for example. So even if 100 players are playing on 1 server they are getting different data back. Or If that's not possible I guess my other option is to create "BOT" system for client and "BOT" for server side, because you should be able to play against bots by urself and against BOT when someone leaves/disconnects a game.

    Sorry if some stuff don't make much sense or are not correct, just trying to figure out how things work.

    10 |1200

    Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

    780144128 avatar image
    780144128 answered

    Hi, @SethDu

    • Bot/AI is something can be implemented in the Server build. It is reasonable to keep monitoring the connections in a multiplayer match.

    How to achieve this, is there any relevant documentation?

    10 |1200

    Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

    Write an Answer

    Hint: Notify or tag a user in this post by typing @username.

    Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.