UKismetSystemLibrary::ExecuteConsoleCommand
#include "Kismet/KismetSystemLibrary.h"
Access: public
Specifiers: staticUFUNCTIONBlueprintCallable
Description
Runs an arbitrary console command as if it had been typed into the in-game console. Useful for scripting cvar changes, cheat commands, or engine commands from Blueprint or C++.
Caveats & Gotchas
- • The command string is not validated before execution — a typo silently fails rather than raising a Blueprint error, so check the output log when debugging.
- • Some console commands are compiled out or blocked in shipping builds (e.g. cheat manager commands), so a command that works in PIE may do nothing in a packaged build.
- • If SpecificPlayer is null, the command is routed through the first local player controller, which can produce unexpected results in split-screen or multi-window PIE.
Signature
static void ExecuteConsoleCommand(const UObject* WorldContextObject, const FString& Command, class APlayerController* SpecificPlayer = NULL ) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| WorldContextObject | const UObject* | World context used to resolve the console command target. | — |
| Command | const FString& | Command string to send to the console, exactly as typed at the in-game console. | — |
| SpecificPlayer | class APlayerController* | If specified, routes the command through this player's console instead of the default. | NULL |
Return Type
void Example
Toggle a debug cvar from Blueprint C++
UKismetSystemLibrary::ExecuteConsoleCommand(this, TEXT("stat fps"), nullptr); Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?