Skip to content

Setting Up FConsoleVariables for C++ Debugging

Goal: Create custom console commands (~) to toggle specific debugging features at runtime without recompiling.

  1. Declare a static variable outside your class: static TAutoConsoleVariable<int32> CVarMyDebug(TEXT("MyGame.DebugMode"), 0, TEXT("Toggles my custom debug view."));
  2. In your Tick or Update function, check the value: if (CVarMyDebug.GetValueOnGameThread() > 0) { // Do debug stuff }.