UBlueprintCheatsSubsystem (C++)
The local-player subsystem that owns enabled cheats, registers console commands and hotkeys, and routes execution.
UBlueprintCheatsSubsystem owns enabled cheats for the local player,
registers their console commands and hotkeys, opens the overlay menu,
and routes execution through each script's gates.
- Header:
Source/BlueprintCheats/Public/BlueprintCheatsSubsystem.h - Module:
BlueprintCheats(Runtime)
UCLASS()
class BLUEPRINTCHEATS_API UBlueprintCheatsSubsystem : public ULocalPlayerSubsystem;Lifetime
One instance per ULocalPlayer.
virtual void Initialize(FSubsystemCollectionBase& Collection) override;
virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
virtual void PlayerControllerChanged(APlayerController* NewPlayerController) override;ShouldCreateSubsystem returns false in shipping builds when
bDisableOnShipping is true. Under that combination no subsystem is
spawned, so no cheats, console commands, or hotkeys exist at all.
PlayerControllerChanged keeps OwningPlayerController in sync with
the active controller — the subsystem always has a current controller
to execute against.
Initialize subscribes to UWorld::OnWorldMatchStarting so the
subsystem rebuilds the enabled-script list per match.
Public API
UFUNCTION(BlueprintCallable)
void EnableScript(const TSubclassOf<UBlueprintCheatScript>& ScriptClass);
UFUNCTION(BlueprintCallable)
void EnableScripts(const TArray<TSubclassOf<UBlueprintCheatScript>>& ScriptClasses);
UFUNCTION(BlueprintCallable)
void ExecuteScript(const UBlueprintCheatScript* ScriptToExecute);EnableScript
Enables a single class at runtime: instantiates it, calls OnEnabled,
binds its hotkey, registers its console command if applicable.
Internally calls EnableScript_Internal against the world's first
player controller. For multi-local-player setups, prefer to call this
once per local player's subsystem via ULocalPlayer::GetSubsystem.
EnableScripts
Convenience wrapper that calls EnableScript for each entry.
ExecuteScript
Menu execution path:
LeaveMenu();
if (Script->CanExecute(OwningPlayerController, OutMsg))
{
bSuccess = Script->Execute(OwningPlayerController, OutMsg); // C++ overload
Script->ResetState();
}
LogExecution(Script->GetScriptDisplayName(), OutMsg, bSuccess);This is what the default menu row binds to its execute button. Custom menus and tooling can call it directly.
Internal flow (read-only summary)
| Method | Triggered by | Behavior |
|---|---|---|
OnWorldMatchStarted | UWorld::OnWorldMatchStarting delegate. | Re-registers all enabled scripts and rebinds the menu hotkey for the new world. |
EnableScript_Internal | EnableScript and OnWorldMatchStarted. | Instantiates the class, binds its hotkey, registers its console command. |
OnMenuKeyTriggered | The IMC's menu hotkey input action. | Toggles the cheat menu. Pauses if bPauseGameWithMenu. Sets Game-and-UI input mode. |
OnInputTriggeredScript | A script's bound input action. | Calls ExecuteScriptFromConsole with empty token array. |
OnConsoleCommandExecuted | Registered console command. | Forwards the raw token array to ExecuteScriptFromConsole. |
ExecuteScriptFromConsole | Console / hotkey paths. | CanExecute → ExecuteRawArguments(rawArgs) → log. |
LeaveMenu | Close button or pre-execute cleanup. | Restores Game-only input mode, hides cursor, unpauses, removes the menu widget. |
LogExecution | Both execution paths. | Writes to LogBlueprintCheats and shows on-screen debug text when enabled. |
Registration order on world match start
- Clears
EnabledScripts. - Loads classes from
UBlueprintCheatsSettings::EnabledScripts(project-wide). - Loads classes from
UBlueprintCheatsSettings::WorldEnabledScriptsfor the current world. - If the level uses
ABlueprintCheatsWorldSettings, loads itsWorldCheatScripts. - For each class:
NewObjectan instance, callOnEnabled, bind itsInputAction(Triggeredalways;Ongoingtoo when the script opts in), register its console command (with the prefix fromUBlueprintCheatsSettings::CheatsConsolePrefix). - Adds the configured IMC to the local player's
UEnhancedInputLocalPlayerSubsystemat priority0and bindsUBlueprintCheatsInputMappingContext::MenuHotkeytoOnMenuKeyTriggered.
Hotkey and menu-key bindings are gated off on PLATFORM_MOBILE.
Console commands still register on mobile.
Logging
DECLARE_LOG_CATEGORY_EXTERN(LogBlueprintCheats, Log, All);- Successful runs log at
Display; failures log atError. - Each entry includes the script display name, success/failure, and
the outcome message you set inside
Execute. - On-screen messages (5-second TTL,
FColor::Green/FColor::Red) are gated byUBlueprintCheatsSettings::bDisplayMessagesToPlayer.
Accessing the subsystem
if (ULocalPlayer* LocalPlayer = ...)
{
if (UBlueprintCheatsSubsystem* Cheats = LocalPlayer->GetSubsystem<UBlueprintCheatsSubsystem>())
{
Cheats->EnableScript(MyCheatClass);
}
}