Set Up Matchmaking with Pragma Engine #
This tutorial uses Pragma Engine 0.0.100 to demonstrate how to implement party 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 is a configurable implementation of the Matchmaking Plugin. The WarmBodyMatchmakingPlugin
performs warm body matchmaking, which means it simply matches the first available players together until a complete match is formed. In this tutorial we’ll enable the Warm Body Matchmaking Plugin and the necessary matchmaking-related functions to the Party Plugin we implemented in the Parties tutorial.
Prerequisites:
See also: WarmBodyMatchmaking reference.
Enable the Warm Body Matchmaking Plugin #
Because the WarmBodyMatchmakingPlugin
is a configurable implementation of the Matchmaking Plugin, we can pass specific parameters in our configuration YAML to change its behavior. Enable the plugin by editing 5-ext/config/dev.yml
to add the following config:
game:
pluginConfigs:
MatchmakingService.matchmakingPlugin:
class: "pragma.matchmaking.WarmBodyMatchmakingPlugin"
config:
numberOfTeams: 1
playersPerTeam: 2
This configuration enables the WarmBodyMatchmakingPlugin
by adding it as a configuration value under the Matchmaking service, and sets the numberOfTeams
value to 1 and the playersPerTeam
value to 2. 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.
Define matchmaking queues #
Matchmaking queues are identified by distinct matchmaking keys. Matchmaking keys are configurable using the ExtMatchmakingKey
proto. In this example, we’ll add the game mode we defined in the Party Plugin tutorial to ExtMatchmakingKey
so that when in matchmaking, one matchmaking queue will be created for each game mode.
- In your
5-ext/ext-protos/src/main/proto/shared/matchmakingExt.proto
file, edit the existingExtMatchmakingKey
messages to match the code below:
message ExtMatchmakingKey {
party.GameMode game_mode = 1;
}
- Next, we need to implement the
buildMatchmakingKey()
function to build theExtMatchmakingKey
according to the party game mode. This method must be implemented in theTutorialPartyPlugin
we created in the Implement the Party Plugin tutorial.
override suspend fun buildMatchmakingKey(party: Party): ExtMatchmakingKey {
val partyExt: ExtParty = party.ext
return ExtMatchmakingKey.newBuilder()
.setGameMode(partyExt.selectedGameMode)
.build()
}
Rebuild the exts #
Because we implemented new functionality in our Party Plugin, we’ll need to rebuild 5-ext
. Run the following command in a terminal from the platform directory:
make ext