Put it all together - Quick match with dedicated servers - (Unity module)
Last updated on March 22, 2024
Connect the UI to start, cancel, and display the matchmaking status
In this tutorial, you will call the dedicated server (DS) matchmaking function in the MatchmakingSessionDSWrapper_Starter
class from the MatchmakingSessionDSHandler_Starter
class.
Open
MatchmakingSessionDSHandler_Starter
. ModifyClickDedicatedServerButton
as shown below. This code will prepare the AccelByte Gaming Services (AGS) Game SDK service wrapper and start matchmaking based on the Match Pool name.public void ClickDedicatedServerButton()
{
var menu = MenuManager.Instance.GetCurrentMenu();
if (menu is MatchmakingSessionServerTypeSelection serverTypeSelection)
{
InitWrapper();
selectedGameMode = serverTypeSelection.SelectedGameMode;
}
else
{
BytewarsLogger.LogWarning("Current menu is not server type selection menu while try to matchmaking with DS");
return;
}
switch (selectedGameMode)
{
case InGameMode.OnlineDeathMatchGameMode:
string teamdeathMatchPoolName = teamdeathmatchWithDSMatchPoolName;
if (GConfig.IsUsingAMS())
{
teamdeathMatchPoolName = teamDeathmatchDSAMSMatchPool;
}
matchmakingSessionDSWrapper.StartDSMatchmaking(teamdeathMatchPoolName);
ShowLoading("Finding Team Death Match (Dedicated Server)...",
"Finding Team Death Match (Dedicated Server) is timed out",
matchmakingTimeoutSec, CancelDSMatchmaking);
break;
case InGameMode.OnlineEliminationGameMode:
string eliminationMatchPoolName = eliminationWithDSMatchPoolName;
if (GConfig.IsUsingAMS())
{
eliminationMatchPoolName = eliminationDSAMSMatchPool;
}
matchmakingSessionDSWrapper.StartDSMatchmaking(eliminationMatchPoolName);
ShowLoading("Finding Elimination Match (Dedicated Server)...",
"Finding Elimination Match (Dedicated Server) is timed out",
matchmakingTimeoutSec, CancelDSMatchmaking);
break;
default:
string errorMsg = $"No Dedicated Server Match Pool for {selectedGameMode}";
BytewarsLogger.LogWarning(errorMsg);
ShowError(errorMsg);
break;
}
}
Now, when you quick play using the Elimination game mode using a dedicated server, the game will start a dedicated server matchmaking via the MatchmakingSessionDSWrapper_Starter
class.
Resources
- The files used in this tutorial section is available in the ByteWars GitHub repository.