Configs
This API is used to retrieve configurations from the Gamebeast platform.
For more information about Configurations, visit the Configurations Guide.
#include "GamebeastConfigs.h"
UGamebeastConfigs* GamebeastConfigs = UGamebeastSubsystem::Get(this)->GetConfigs();Values are addressed by dot-path where the first segment is the configuration alias: "MyConfig.PlayerSpeed" reads the PlayerSpeed key of the MyConfig configuration. Paths can reach deeper ("MyConfig.UI.ButtonColor") and index arrays ("MyConfig.Levels.0"). A bare alias ("MyConfig") is the whole configuration document.
Configurations are evaluated for the local player: if they are enrolled in an active experiment, the values already include the assigned group's changes.
Configurations load on demand: the first read fetches the configuration. Listing configurations in Configurations (setup options or Project Settings) also loads them at startup and lets OnReady wait for them. Every configuration is cached on the device, so values are there instantly on the next launch and offline. A cache written by a different build (Project Settings > Description > Project Version) or for a different player is discarded.
Loaded configurations stay current on their own. Every 30 seconds (the StatusPollRate rate) the SDK asks Gamebeast whether anything changed, and re-evaluates only the configurations that did. Configurations with a running experiment are also re-evaluated every 60 seconds (AssignmentRefreshRate), so a change to one player, such as moving them to another group, reaches them mid-session. In the editor both run at their minimums (5 and 10 seconds). Use OnChanged or Observe to run your code when a value changes.
GetFloat, GetInt, GetBool, GetString (Path, DefaultValue)
float / int32 / bool / FStringreturn type
Reads a value. Returns DefaultValue when the configuration hasn't loaded yet, the path is missing, or the value has a different JSON type (a string where a number was expected, for example). That makes DefaultValue both a fallback and a type check. Each problem is logged once (per configuration, or per path for a type mismatch), so reading every frame doesn't flood the log. Always pass the value your game uses today as the default, so it behaves the same offline.
PathFStringThe path of the value, starting with the configuration alias.
DefaultValuefloat / int32 / bool / FStringReturned when the value isn't available.
Usage
const float PlayerSpeed = GamebeastConfigs->GetFloat(TEXT("MyConfig.PlayerSpeed"), 600.f);
const int32 StartingCoins = GamebeastConfigs->GetInt(TEXT("MyConfig.Economy.StartingCoins"), 100);GetJsonString(Path, DefaultValue) and GetJson(Path)
FString / TSharedPtr<FJsonValue>return type
GetJsonString returns any value, objects and arrays included, as JSON text. In C++, GetJson returns the value itself (null when unavailable), which you can turn into a USTRUCT with FJsonObjectConverter:
#include "JsonObjectConverter.h"
FMyShopConfig Shop;
const TSharedPtr<FJsonValue> Value = GamebeastConfigs->GetJson(TEXT("MyConfig.Shop"));
if (Value.IsValid() && Value->Type == EJson::Object)
{
FJsonObjectConverter::JsonObjectToUStruct(Value->AsObject().ToSharedRef(), &Shop);
}HasValue(Path)
boolreturn type
Whether the path resolves to a value right now.
IsReady()
boolreturn type
Whether every configuration listed in Configurations has loaded (from the network or the device cache). True right after Setup when none are listed.
OnReady(Callback) and OnReadyEvent
voidreturn type
OnReady runs a C++ callback once IsReady is true, immediately if it already is. In Blueprint, bind On Ready Event before calling Setup, or check Is Ready first.
Usage
GamebeastConfigs->OnReady([this]()
{
ApplySpeed(UGamebeastSubsystem::Get(this)->GetConfigs()->GetFloat(TEXT("MyConfig.PlayerSpeed"), 600.f));
});OnChanged(Path, Callback)
int64return type
Calls Callback with the new value whenever the value at Path changes. It does not fire for the first load; use Observe for that. Returns a handle for Unsubscribe. The value is null when the path was removed.
Usage
GamebeastConfigs->OnChanged(TEXT("MyConfig.PlayerSpeed"),
FGamebeastConfigValueCallback::CreateLambda([](const TSharedPtr<FJsonValue>& Value)
{
UE_LOG(LogTemp, Log, TEXT("PlayerSpeed is now %s"), Value.IsValid() ? *Value->AsString() : TEXT("unset"));
}));Observe(Path, Callback)
int64return type
Like OnChanged, but also calls Callback with the current value as soon as there is one. The best fit for values that may still be loading.
Usage
ObserveHandle = GamebeastConfigs->Observe(TEXT("MyConfig.PlayerSpeed"),
FGamebeastConfigValueCallback::CreateUObject(this, &AMyCharacter::HandleSpeedChanged));
// Later, e.g. in EndPlay:
GamebeastConfigs->Unsubscribe(ObserveHandle);Bind with CreateUObject or CreateWeakLambda so a destroyed actor is never called back.
OnConfigurationUpdated
Blueprint event, with the alias of a configuration that just loaded new values. Read the values you need again.
Preload(Alias)
voidreturn type
Starts loading a configuration that isn't listed in Configurations, without reading from it yet.
Refresh()
voidreturn type
Checks for changes now instead of waiting for the next check: asks Gamebeast whether anything changed, and re-evaluates every known configuration for the local player. Unchanged configurations cost almost nothing: the SDK sends the hash it has, and the server answers "unchanged". The SDK does this by itself when the game returns from the background.