# Starting Matchmaking

In order to access online features, the player must be logged in with the **Online Subsystem**. Please visit the [**Authentication**](/kronos-matchmaking/usage/authentication/authenticating-users.md) page for more information.

## Matchmaking

You can start matchmaking by using the `StartKronosMatchmaking` node. To make the required matchmaking parameters simply drag off of the "Matchmaking Params" property and search for "make". You can also do the same for the "Host Params".

There is no hard requirement on where you need to call this from. Most games will probably have this hooked to the `OnClicked` event of a widget button.

{% tabs %}
{% tab title="Blueprint" %}

<figure><img src="/files/63hgN6xmEck3PO42Q075" alt=""><figcaption></figcaption></figure>
{% endtab %}

{% tab title="C++" %}

```cpp
#include "KronosMatchmakingManager.h"
#include "KronosPartyManager.h"
#include "KronosMatchmakingPolicy.h"
```

```cpp
// Get the matchmaking manager.
UKronosMatchmakingManager* MatchmakingManager = UKronosMatchmakingManager::Get(this);

// Request a new matchmaking policy. This operation is async!
// If matchmaking is in-progress, it will be canceled first.
MatchmakingManager->CreateMatchmakingPolicy(FOnCreateMatchmakingPolicyComplete::CreateLambda([this](UKronosMatchmakingPolicy* MatchmakingPolicy)
{
    // Parameters to be used when matchmaking results in creating a session.
    FKronosHostParams HostParams;
    HostParams.StartingLevel = TEXT("MyMap");
    HostParams.Playlist = TEXT("TeamDeathmatch");
    HostParams.MaxNumPlayers = 4;
    HostParams.bShouldAdvertise = true;
    HostParams.bIsLanMatch = false;
    HostParams.bUsesPresence = true;
    
    // Parameters to be used for matchmaking.
    FKronosMatchmakingParams MatchmakingParams;
    MatchmakingParams.HostParams = HostParams;
    MatchmakingParams.Playlist = TEXT("TeamDeathmatch");
    MatchmakingParams.MaxSearchAttempts = 3;
    MatchmakingParams.MaxSearchResults = 20;
    MatchmakingParams.MinSlotsRequired = UKronosPartyManager::Get(this)->GetPartySize();
    MatchmakingParams.bIsLanQuery = false;
    MatchmakingParams.bSearchPresence = true;
    
    // Flags for matchmaking (e.g. use EKronosMatchmakingFlags::NoHost if you don't want matchmaking to result in hosting).
    uint8 MatchmakingFlags = static_cast<uint8>(EKronosMatchmakingFlags::None);
    
    // Start matchmaking.
    // Notice that we are using NAME_GameSession!
    MatchmakingPolicy->StartMatchmaking(NAME_GameSession, MatchmakingParams, MatchmakingFlags, EKronosMatchmakingMode::Default);
}));
```

{% endtab %}
{% endtabs %}

{% hint style="success" %}
After matchmaking is complete the player will join the game automatically. We do not need to do anything else.
{% endhint %}

### The Host Params

The "Host Params" is going to be used if the matchmaking results in creating a new session. It is the same set of parameters that you use to create matches with. For more information please refer to the [**Creating Matches**](/kronos-matchmaking/usage/matchmaking/creating-matches.md) section of the documentation.

{% hint style="info" %}
The "Host Params" can be left empty if the `NoHost` option is enabled in the "Matchmaking Flags".
{% endhint %}

### The Min Slots Required Param

The "Min Slots Required" param tells the matchmaking system to ignore sessions that do not have at least X amount of open slots. We can use the `GetPartySize` node to easily determine how many slots we need. This node returns the number of players in the party, or 1 if the player is not in a party. By using this we basically avoid sessions that we would not fit.

### The Playlist Params

The "Playlist", "Map Name", and "Game Mode" params are purely cosmetic information used for session filtering. When these parameters are given for the matchmaking, sessions have to match their corresponding params to be considered for joining. If left empty, all sessions will be considered as valid. As an example I'm going to set my playlist params to the following (without the quotes):

* Playlist: "PVP"
* Map Name: -
* Game Mode: "Deathmatch"

I have intentionally left the "Map Name" empty so that it will not be considered. I just want to find a "Deathmatch" game, I do not care which map it is currently being played on.

### Elo Skill Rating Params

Please refer to the [**Using Skill Ratings**](/kronos-matchmaking/usage/matchmaking/using-skill-ratings.md) section of the documentation.

### Extra Query Settings

The "Extra Query Settings" param allows you to add custom **Query Settings** that the matchmaking will use during session searches. These settings are essentially filters that will compare against the session's corresponding **Session Setting**.

{% hint style="warning" %}
**IMPORTANT:** Different Online Subsystems may not support all types of query settings. The Steam Online Subsystem for example does not support `bool` settings.
{% endhint %}

It is important to note that Kronos has a two layer session filtering process. First, sessions will be queried by the **Online Subsystem** using the given settings. Once sessions are found, all results will be filtered again. This was necessary due to the **Null Online Subsystem** not handling query settings.

Query settings registered with the "Extra Query Settings" param are used for filtering at both layers automatically. However, if you are not registering query settings through this param, then you have to override the `FilterSearchResult` function of the `KronosMatchmakingSearchPass` in C++ and handle your query settings manually. Again, you only need to do this if you are not using the "Extra Query Settings" param.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://horizongames.gitbook.io/kronos-matchmaking/usage/matchmaking/starting-matchmaking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
