ShowFlag.DebugAI
ShowFlag.DebugAI
#Overview
name: ShowFlag.DebugAI
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Allows to override a specific showflag (works in editor and game, \
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ShowFlag.DebugAI is to enable debug drawing for AI systems in Unreal Engine 5. This setting variable is primarily used for developer debugging and visualization of AI-related functionality.
This setting variable is relied upon by the following Unreal Engine subsystems and modules:
- AIModule: This module uses the DebugAI flag to control the display of AI debug information, including path data and pawn icons.
- GameplayDebugger: This module uses the flag to determine whether to activate or deactivate the gameplay debugger mode for AI.
- Engine: The engine’s show flags system includes this flag for general AI debugging purposes.
The value of this variable is set in the engine’s show flags system, specifically in the ShowFlagsValues.inl
file. It is defined as a fixed show flag that is not available in shipping builds, indicating its use for development and debugging purposes only.
The DebugAI flag interacts with other debugging-related variables, such as VisLog, Navigation, and GameplayDebug. These flags work together to provide a comprehensive debugging environment for AI and gameplay systems.
Developers should be aware of the following when using this variable:
- It is only available in non-shipping builds, so it should not be relied upon for any gameplay or release-critical functionality.
- Enabling this flag may have performance implications, as it triggers additional debug drawing calls.
- It is primarily used in editor and development contexts, not in final game builds.
Best practices for using this variable include:
- Use it judiciously during development and testing phases to diagnose AI-related issues.
- Ensure it is disabled in performance-critical scenarios or when profiling the game.
- Combine it with other debug flags (like Navigation or GameplayDebug) for a more comprehensive view of the AI system’s behavior.
Regarding the associated variable DebugAI:
The purpose of DebugAI is the same as ShowFlag.DebugAI, as they share the same value. It is used in various AI-related debugging contexts, such as in the GameplayDebuggerCategory_AI class for collecting path data and drawing debug information for AI controllers and pawns.
This variable is primarily used in the AIModule and GameplayDebugger subsystems. It is typically set through the engine’s show flags system, which then propagates to the DebugAI variable in relevant code sections.
Developers should be aware that this variable is used in conjunction with other AI debugging tools and components, such as the GridPathFollowingComponent and the GameplayDebuggerLocalController.
Best practices for using DebugAI include:
- Use it in conjunction with other AI debugging tools for a comprehensive view of AI behavior.
- Be aware of its impact on performance, especially when debugging complex AI systems.
- Ensure it is properly disabled in release builds to prevent any potential performance or security issues.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:163
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(IndirectLightingCache, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "IndirectLightingCacheSF", "Indirect Lighting Cache"))
/** calls debug drawing for AIs */
SHOWFLAG_FIXED_IN_SHIPPING(0, DebugAI, SFG_Developer, NSLOCTEXT("UnrealEd", "DebugAISF", "AI Debug"))
/** calls debug drawing for whatever LogVisualizer wants to draw */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisLog, SFG_Developer, NSLOCTEXT("UnrealEd", "VisLogSF", "Log Visualizer"))
/** whether to draw navigation data */
SHOWFLAG_FIXED_IN_SHIPPING(0, Navigation, SFG_Normal, NSLOCTEXT("UnrealEd", "NavigationSF", "Navigation"))
/** used by gameplay debugging components to debug-draw on screen */
SHOWFLAG_FIXED_IN_SHIPPING(0, GameplayDebug, SFG_Developer, NSLOCTEXT("UnrealEd", "GameplayDebugSF", "Gameplay Debug"))
#Associated Variable and Callsites
This variable is associated with another variable named DebugAI
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Editor/GameplayDebugger/Private/GameplayDebuggerEdMode.cpp:103
Scope (from outer to inner):
file
function void FGameplayDebuggerEdMode::Tick
Source code excerpt:
void FGameplayDebuggerEdMode::Tick(FEditorViewportClient* ViewportClient, float DeltaTime)
{
if (ViewportClient == nullptr || !ViewportClient->EngineShowFlags.DebugAI)
{
Owner->DeactivateMode(FGameplayDebuggerEdMode::EM_GameplayDebugger);
}
}
void FGameplayDebuggerEdMode::SafeOpenMode()
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/GameplayDebugger/GameplayDebuggerCategory_AI.cpp:215
Scope (from outer to inner):
file
function void FGameplayDebuggerCategory_AI::CollectPathData
Source code excerpt:
}
void FGameplayDebuggerCategory_AI::CollectPathData(AAIController* DebugAI)
{
UPathFollowingComponent* PathComp = DebugAI ? DebugAI->GetPathFollowingComponent() : nullptr;
DataPack.bIsUsingPathFollowing = (PathComp != nullptr);
if (PathComp)
{
TArray<FString> Tokens;
TArray<EPathFollowingDebugTokens::Type> Flags;
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/GameplayDebugger/GameplayDebuggerCategory_NavLocalGrid.cpp:398
Scope (from outer to inner):
file
function void FGameplayDebuggerCategory_NavLocalGrid::CollectData
Source code excerpt:
const APawn* DebugPawn = Cast<APawn>(DebugActor);
const AAIController* DebugAI = DebugPawn ? Cast<AAIController>(DebugPawn->GetController()) : nullptr;
const UGridPathFollowingComponent* GridPathComp = DebugAI ? Cast<UGridPathFollowingComponent>(DebugAI->GetPathFollowingComponent()) : nullptr;
if (GridPathComp && GridPathComp->HasActiveGrid() && GridManager)
{
const int32 CurrentGridIdx = GridPathComp->GetActiveGridIdx();
if (CurrentGridIdx >= 0 && CurrentGridIdx < GridManager->GetNumGrids())
{
AgentDataPack.GridIdx = CurrentGridIdx;
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Public/GameplayDebugger/GameplayDebuggerCategory_AI.h:30
Scope (from outer to inner):
file
class class FGameplayDebuggerCategory_AI : public FGameplayDebuggerCategory
Source code excerpt:
protected:
void CollectPathData(AAIController* DebugAI);
void DrawPath(UWorld* World);
void DrawPawnIcons(UWorld* World, AActor* DebugActor, APawn* SkipPawn, FGameplayDebuggerCanvasContext& CanvasContext);
void DrawOverheadInfo(AActor& DebugActor, FGameplayDebuggerCanvasContext& CanvasContext);
struct FRepData
{
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Public/ShowFlagsValues.inl:163
Scope: file
Source code excerpt:
SHOWFLAG_ALWAYS_ACCESSIBLE(IndirectLightingCache, SFG_LightingFeatures, NSLOCTEXT("UnrealEd", "IndirectLightingCacheSF", "Indirect Lighting Cache"))
/** calls debug drawing for AIs */
SHOWFLAG_FIXED_IN_SHIPPING(0, DebugAI, SFG_Developer, NSLOCTEXT("UnrealEd", "DebugAISF", "AI Debug"))
/** calls debug drawing for whatever LogVisualizer wants to draw */
SHOWFLAG_FIXED_IN_SHIPPING(0, VisLog, SFG_Developer, NSLOCTEXT("UnrealEd", "VisLogSF", "Log Visualizer"))
/** whether to draw navigation data */
SHOWFLAG_FIXED_IN_SHIPPING(0, Navigation, SFG_Normal, NSLOCTEXT("UnrealEd", "NavigationSF", "Navigation"))
/** used by gameplay debugging components to debug-draw on screen */
SHOWFLAG_FIXED_IN_SHIPPING(0, GameplayDebug, SFG_Developer, NSLOCTEXT("UnrealEd", "GameplayDebugSF", "Gameplay Debug"))
#Loc: <Workspace>/Engine/Source/Runtime/GameplayDebugger/Private/GameplayDebuggerLocalController.cpp:72
Scope (from outer to inner):
file
function void UGameplayDebuggerLocalController::Initialize
Source code excerpt:
#if WITH_GAMEPLAY_DEBUGGER_MENU
UDebugDrawService::Register(bSimulateMode ? TEXT("DebugAI") : TEXT("Game"), FDebugDrawDelegate::CreateUObject(this, &UGameplayDebuggerLocalController::OnDebugDraw));
#if WITH_EDITOR
if (bSimulateMode)
{
FGameplayDebuggerModule::OnLocalControllerInitialized.Broadcast();
}