Set Up Matchmaking with Pragma Engine #
This tutorial uses Pragma Engine 0.3.0 to demonstrate how to implement matchmaking functionality.
Pragma Engine uses a Matchmaking Plugin to provide matchmaking functionality. You can build your own matchmaking plugins to customize matchmaking behavior to suit the unique needs of your game.
As this is a simplified tutorial, we’ll be using the Pragma-provided WarmBodyMatchmakingPlugin
matchmaking plugin, which matches the first n players together. We’ll also add the necessary matchmaking-related functions to the Party Plugin we implemented in the Parties tutorial.
1. Enable the Warm Body Matchmaking Plugin #
Goal: Enable the the WarmBodyMatchmakingPlugin
plugin.
Steps #
Because the WarmBodyMatchmakingPlugin
is a configurable implementation of the Matchmaking Plugin, we can pass specific parameters in our configuration YAML to change its behavior. Ensure the WarmBodyMatchmakingPlugin
is enabled in 5-ext/config/local-dev.yml
. For ease of testing, set the numberOfTeams
value to 2 and the playersPerTeam
value to 1.
game:
pluginConfigs:
MatchmakingService.matchmakingPlugin:
class: "pragma.matchmaking.WarmBodyMatchmakingPlugin"
config:
numberOfTeams: 2
playersPerTeam: 1
Default logic in the WarmBodyMatchmakingPlugin
dictates that a game instance will be started when there are exactly enough players to satisfy the Config.playersPerTeam
and Config.numberOfTeams
configuration, and ensures the parties are in the same game mode.
2. Define matchmaking queues #
Goal: Use the game mode we defined in the Party Plugin tutorial to ensure a separate matchmaking queue will be created for each game mode.
Matchmaking queues are identified by distinct matchmaking keys. Matchmaking keys are configurable using the ExtMatchmakingKey
proto.
Steps #
a. In your 5-ext/ext-protos/src/main/proto/shared/matchmakingExt.proto
file, edit the existing ExtMatchmakingKey
messages to match the code below:
message ExtMatchmakingKey {
party.GameMode game_mode = 1;
}
Note: Make sure to import “shared/partyRpcExt.proto”;
b. Build the protos so they’re available for use when implementing the Party Plugin by running the following command in the terminal from the platform directory:
make ext-protos
3. Override the Matchmaking Key function #
Goal: Build the matchmaking key according to the party game mode.
Steps #
a. The buildMatchmakingKey()
function must be implemented in the TutorialPartyPlugin
we created in the Implement the Party Plugin tutorial.
override suspend fun buildMatchmakingKey(party: Party.Party): ExtMatchmakingKey {
val partyExt: ExtParty = party.ext
return ExtMatchmakingKey.newBuilder()
.setGameMode(partyExt.selectedGameMode)
.build()
}
b. Recompile 5-ext
. Run the following command in a terminal from the platform directory:
make ext
Next steps #
Congratulations! You now have a custom implementation of the WarmBodyMatchmaking Plugin. Continue to the Social tutorial or see how to apply the WarmBodyMatchmaking Plugin in Unreal.