Skip to main content

Display challenges in the game client

Last updated on October 24, 2024

Overview

AccelByte Gaming Services (AGS) Challenge allows you to display active challenges for players to undertake and their progress towards completing those challenges. This article provides information on how to display the challenges and their progress, goals, and rewards that you've integrated with AGS Challenge using the AGS Gaming SDK.

Prerequisites

  • The AGS Game SDK installed and configured into your Unreal or Unity project.
  • An IAM client set up for your game, and access to that IAM client's ID and secret.
  • Challenges integrated into your project with AGS Challenge.

Display challenge in the game client

After you have your challenge configurations set up, you can retrieve them to either display in the game client or access their code.

Retrieve and display all available challenges

You can retrieve all available challenge configurations and display them in the game client by using this code:

AccelByte::FMultiRegistry::GetApiClient()->Challenge.GetChall6enges(THandler<FAccelByteModelsGetChallengesResponse>::CreateLambda([]
(const FAccelByteModelsGetChallengesResponse& Response)
{
for (auto ChallengeData : Response.Data)
{
UE_LOG(LogTemp, Warning, TEXT("Challenge Name: %s Status: %s"),
*ChallengeData.Name, *FAccelByteUtilities::GetUEnumValueAsString(ChallengeData.Status));
// more various things to do with the challenge data
}
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT("[%d]: %s"),
ErrorCode, *ErrorMessage);
}));

Retrieve and display a specific challenge

Example of Daily Mission UI implementation

You can retrieve a specific challenge configuration and display it in the game client by using this code:

const FString& ChallengeCode = TEXT("specific-challenge-code");
AccelByte::FMultiRegistry::GetApiClient()->Challenge.GetScheduledChallengeGoals(
ChallengeCode, THandler<FAccelByteModelsGetScheduledChallengeGoalsResponse>::CreateLambda([]
(const FAccelByteModelsGetScheduledChallengeGoalsResponse& Response)
{
for (auto ChallengeGoalData : Response.Data)
{
UE_LOG(LogTemp, Warning, TEXT("Goal Name: %s Description: %s IsActive: %hhd"),
*ChallengeGoalData.Name, *ChallengeGoalData.Description, ChallengeGoalData.IsActive)
}
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT("[%d]: %s"),
ErrorCode, *ErrorMessage);
}));

Display player progress

Example of Challenge progress UI implementation

You can retrieve the player's progression toward completing a challenge and display it in the game client by using this code:

const FString& ChallengeCode = TEXT("specific-challenge-code");
const FString& GoalCode = TEXT("specific-goal-code");
AccelByte::FMultiRegistry::GetApiClient()->Challenge.GetChallengeProgress(
ChallengeCode, GoalCode, THandler<FAccelByteModelsChallengeProgressResponse>::CreateLambda([]
(const FAccelByteModelsChallengeProgressResponse& Response)
{
for (auto ChallengeGoalProgressData : Response.Data)
{
UE_LOG(LogTemp, Warning, TEXT("Goal Code: %s Status: %s"),
*ChallengeGoalProgressData.GoalCode, *FAccelByteUtilities::GetUEnumValueAsString(ChallengeGoalProgressData.Status));
}
}), FErrorHandler::CreateLambda([](int32 ErrorCode, const FString& ErrorMessage)
{
UE_LOG(LogTemp, Warning, TEXT("[%d]: %s"),
ErrorCode, *ErrorMessage);
}));