👥Matchmaking
Integrating Matchmaking with PlayFlow
Last updated
Integrating Matchmaking with PlayFlow
Last updated
Have a question? We're here to help. Reach out to us on Discord.
PlayFlow's matchmaking system is designed to streamline the process of bringing players together in a game. When a player opts for matchmaking, they're placed into a matchmaking pool. This pool is where the magic happens — it's an aggregation point for all players looking to join a game.
Matchmaking Pool: As players initiate matchmaking, they are added to a matchmaking pool. This pool serves as a temporary holding area where players await pairing based on the matchmaking criteria.
Criteria-Based Matching: Players can be matched based on specific criteria, such as skill level (Elo), regions, game type preferences, or custom parameters. If no criteria are defined, the system will default to matching players without discrimination, ensuring that everyone gets into a game as swiftly as possible.
Server Launching: Once suitable matches are made, PlayFlow takes care of the rest by automatically launching a dedicated server for the matched players. This seamless process ensures that players can jump straight into the action without worrying about server setup or availability.
Dynamic Matchmaking Engine: At the heart of PlayFlow's matchmaking system is a dynamic engine designed to ensure players are matched together efficiently. This engine constantly adjusts to the pool of waiting players and their respective criteria, aiming to minimize wait times while optimizing match relevance.
This dynamic approach to matchmaking means that the system is continually working to find the best possible matches for players at any given moment, adapting to the ever-changing pool of participants. The result is a more enjoyable gaming experience, where players spend less time waiting and more time playing.
The matchmaking configuration in PlayFlow allows you to customize the parameters for creating matches. These parameters help define how players are grouped together based on various criteria such as skill level, wait times, and player count. You should define this in your project's configuration settings in your PlayFlow dashboard. Here is an example of a simple matchmaker configuration:
type: Specifies the type of game server size. Example: "small"
min_players: The minimum number of players required to start a match. Example: 1
max_players: The maximum number of players allowed in a match. Example: 8
max_elo_difference: The maximum allowable difference in ELO (skill rating) between players in the match. Example: 1000
wait_timeout: The maximum time (in seconds) to wait for additional players before starting the match. Example: 30
backfill: A boolean indicating whether backfill is enabled (i.e., whether the match can accept additional players after it has started). Example: false
1. Triggering Matchmaking
To initiate matchmaking, you can set up an input trigger or a button in the UI. In this example, pressing the K
key begins the matchmaking process:
2. Setting Up Player Data
Create a new instance of PlayFlowManager.PlayerData
to hold the player's information:
3. Assigning a Unique Identifier
Assign a unique identifier to each player. This example uses the device's unique identifier:
4. Specifying Region Preferences
Define the player's preferred regions for matchmaking to ensure lower latency:
5. (Optional) Using Elo for Matchmaking
If you're implementing skill-based matchmaking, specify the player's Elo:
6. Setting the Game Type
Indicate the game type the player wishes to engage in. This helps in matching players interested in the same game mode:
7. Adding Custom Parameters (Optional)
For more refined matchmaking, you can include custom parameters:
8. Initiating Matchmaking
Call PlayFlowManager.FindMatch
with the necessary parameters, including the clientToken
, playerData
, and a callback method OnMatchFound
to handle the match found event:
Full Example:
This method encapsulates the entire process from initiating matchmaking with a key press to handling the outcome when a match is found.
Once a match is found, the OnMatchFound
method is crucial for managing the transition of the player into the matched game session. This method should not only acknowledge the match but also initiate the connection process to the designated game server.
OnMatchFound Method
This method logs the matched server details and checks for the availability of port 443, typically used for secure connections. If available, it proceeds to initiate a connection.
StartConnection Method
This method attempts to establish a connection to the game server by calling a coroutine, StartConnectionCoroutine
, up to three times to ensure a robust connection attempt.
StartConnectionCoroutine Method
The coroutine waits for 2 seconds before logging the connection attempt and starting the connection. It configures the Bayou
WebSockets transport (FishNet) component for a WebSocket Secure (WSS) connection using the given URL and port, and then attempts to start the connection.
Incorporating these methods into your PlayFlow integration ensures a smooth transition from matchmaking to game session connection, enhancing the overall player experience.