Set Up Matchmaking with Pragma Engine #

This tutorial uses Pragma Engine 0.0.101 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 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

1. Enable the Warm Body Matchmaking Plugin #

Goal #

Enable the the WarmBodyMatchmakingPlugin plugin using the YAML file.

Steps #

  1. 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: 2
        playersPerTeam: 1

This configuration enables the WarmBodyMatchmakingPlugin by adding it as a configuration value under the Matchmaking service. For ease of testing, we set the numberOfTeams value to 2 and the playersPerTeam value to 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 ensure the parties are in the same game mode.

2. Define matchmaking queues #

Goal #

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.

Steps #

Matchmaking queues are identified by distinct matchmaking keys. Matchmaking keys are configurable using the ExtMatchmakingKey proto.

  1. 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;
}
  1. 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 #

Implement the buildMatchmakingKey() function to build the ExtMatchmakingKey according to the party game mode.

Steps #

  1. 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()
}
  1. 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. See how to apply the WarmBodyMatchmaking Plugin in Unreal, or continue to the Social tutorial.