You can create new Console variables in Unreal by using TAutoConsoleVariable.
static TAutoConsoleVariable<bool> MyCVar(
TEXT("variablename"),
true,
TEXT("description of the variable's purpose"),
ECVF_Cheat
);
This creates a new variable, which can be modified using variablename
in the console. It defaults to true
, and has a description. It’s marked as ECVF_Cheat
, which automatically disables the variable in packaged builds. See the IConsoleManager.h
file for a full list of possible ECVF
values.
Accessing auto console variables is simple:
bool Val = MyCVar.GetValueOnGameThread();
They have other functions as well, which should be self-explanatory if you check their comments and naming.