Joining Matches
Last updated
Last updated
In order to access online features, the player must be logged in with the Online Subsystem. Please visit the Authentication page for more information.
You can directly join a match by using the JoinKronosMatch
node. Note that you only have to do this if you specifically told the matchmaking system to only search for games. Otherwise players join the game during matchmaking automatically. You will most likely only ever use this for a server browser.
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.
You find matches by using the FindKronosMatches
node. This will give you an array of KronosSearchResult
that you can iterate over (e.g. to create entries for a server browser).
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.
#include "KronosMatchmakingManager.h"
#include "KronosPartyManager.h"
#include "KronosMatchmakingPolicy.h"
// 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 for matchmaking.
FKronosMatchmakingParams MatchmakingParams;
MatchmakingParams.Playlist = TEXT("TeamDeathmatch");
MatchmakingParams.MaxSearchAttempts = 3;
MatchmakingParams.MaxSearchResults = 20;
MatchmakingParams.MinSlotsRequired = 0;
MatchmakingParams.bIsLanQuery = false;
MatchmakingParams.bSearchPresence = true;
// Matchmaking flags to use.
// You could use EKronosMatchmakingFlags::SkipEloChecks.
uint8 MatchmakingFlags = static_cast<uint8>(EKronosMatchmakingFlags::None);
// Tell the matchmaking that we only want to search for sessions.
EKronosMatchmakingMode MatchmakingMode = EKronosMatchmakingMode::SearchOnly;
// Start matchmaking.
// Notice that we are using NAME_GameSession!
MatchmakingPolicy->StartMatchmaking(NAME_GameSession, MatchmakingParams, MatchmakingFlags, MatchmakingMode);
}));