ai.crowd.DrawDebugPath
ai.crowd.DrawDebugPath
#Overview
name: ai.crowd.DrawDebugPath
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Draw active paths, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable
It is referenced in 8
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ai.crowd.DrawDebugPath is to enable or disable the drawing of active paths for crowd agents in the Unreal Engine’s AI module. This setting variable is primarily used for debugging and visualization purposes in the crowd simulation system.
This setting variable is mainly used in the AI Module of Unreal Engine, specifically within the CrowdManager subsystem. It’s part of the crowd simulation and navigation features of the engine.
The value of this variable is set using a console variable (cvar) system. It’s initialized with a default value of 1 (enabled) and can be changed at runtime through the console or code.
The associated variable DrawDebugPath interacts with it directly. They share the same value and purpose, with the console variable controlling the behavior of the DrawDebugPath function.
Developers should be aware that:
- This debug feature requires ai.crowd.DebugSelectedActors to be set for it to work.
- It’s a performance-impacting feature and should be used judiciously, especially in production builds.
- The debug drawing is only visible when the game is running with the appropriate debug views enabled.
Best practices when using this variable include:
- Use it primarily during development and testing phases.
- Disable it in release builds to avoid unnecessary performance overhead.
- Combine it with other debug variables like ai.crowd.DebugSelectedActors for more comprehensive debugging.
- Be cautious when using it in multiplayer scenarios, as it might affect network performance.
Regarding the associated variable DrawDebugPath: This is a function in the UCrowdManager class that actually performs the debug drawing of the paths. It’s called when the ai.crowd.DrawDebugPath console variable is set to 1. The function visualizes the active paths of crowd agents, which can be extremely useful for understanding and debugging crowd movement behavior in the game world.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:62
Scope (from outer to inner):
file
namespace FCrowdDebug
Source code excerpt:
int32 DrawDebugPath = 1;
FAutoConsoleVariableRef CVarDrawDebugPath(TEXT("ai.crowd.DrawDebugPath"), DrawDebugPath,
TEXT("Draw active paths, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
int32 DrawDebugVelocityObstacles = 1;
FAutoConsoleVariableRef CVarDrawDebugVelocityObstacles(TEXT("ai.crowd.DrawDebugVelocityObstacles"), DrawDebugVelocityObstacles,
TEXT("Draw velocity obstacle sampling, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
#Associated Variable and Callsites
This variable is associated with another variable named DrawDebugPath
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Classes/Navigation/CrowdManager.h:384
Scope (from outer to inner):
file
class class UCrowdManager : public UCrowdManagerBase
Source code excerpt:
AIMODULE_API void DrawDebugCorners(const dtCrowdAgent* CrowdAgent) const;
AIMODULE_API void DrawDebugCollisionSegments(const dtCrowdAgent* CrowdAgent) const;
AIMODULE_API void DrawDebugPath(const dtCrowdAgent* CrowdAgent) const;
AIMODULE_API void DrawDebugVelocityObstacles(const dtCrowdAgent* CrowdAgent) const;
AIMODULE_API void DrawDebugPathOptimization(const dtCrowdAgent* CrowdAgent) const;
AIMODULE_API void DrawDebugNeighbors(const dtCrowdAgent* CrowdAgent) const;
AIMODULE_API void DrawDebugSharedBoundary() const;
#endif // ENABLE_DRAW_DEBUG
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:61
Scope (from outer to inner):
file
namespace FCrowdDebug
Source code excerpt:
TEXT("Draw colliding navmesh edges, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
int32 DrawDebugPath = 1;
FAutoConsoleVariableRef CVarDrawDebugPath(TEXT("ai.crowd.DrawDebugPath"), DrawDebugPath,
TEXT("Draw active paths, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
int32 DrawDebugVelocityObstacles = 1;
FAutoConsoleVariableRef CVarDrawDebugVelocityObstacles(TEXT("ai.crowd.DrawDebugVelocityObstacles"), DrawDebugVelocityObstacles,
TEXT("Draw velocity obstacle sampling, requires ai.crowd.DebugSelectedActors.\n0: Disable, 1: Enable"), ECVF_Default);
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:1019
Scope (from outer to inner):
file
function void UCrowdManager::DrawDebugPath
Source code excerpt:
}
void UCrowdManager::DrawDebugPath(const dtCrowdAgent* CrowdAgent) const
{
UWorld* DebugDrawingWorld = GetDebugDrawingWorld();
ARecastNavMesh* NavMesh = Cast<ARecastNavMesh>(MyNavData);
if (NavMesh == NULL)
{
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Navigation/CrowdManager.cpp:1185
Scope (from outer to inner):
file
function void UCrowdManager::DebugTick
Source code excerpt:
}
if (FCrowdDebug::DrawDebugPath)
{
DrawDebugPath(SelectedAgent);
}
if (FCrowdDebug::DrawDebugVelocityObstacles)
{
DrawDebugVelocityObstacles(SelectedAgent);
}
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavigationData.cpp:662
Scope (from outer to inner):
file
function void ANavigationData::DrawDebugPath
Source code excerpt:
}
void ANavigationData::DrawDebugPath(FNavigationPath* Path, const FColor PathColor, UCanvas* Canvas, const bool bPersistent, const float LifeTime, const uint32 NextPathPointIndex) const
{
Path->DebugDraw(this, PathColor, Canvas, bPersistent, LifeTime, NextPathPointIndex);
}
double ANavigationData::GetWorldTimeStamp() const
{
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavigationData.cpp:870
Scope (from outer to inner):
file
function void ANavigationData::DrawDebugPath
Source code excerpt:
// deprecated functions
//------------------------------------------------------------------------//
void ANavigationData::DrawDebugPath(FNavigationPath* Path, FColor PathColor, UCanvas* Canvas, bool bPersistent, const uint32 NextPathPointIndex) const
{
DrawDebugPath(Path, PathColor, Canvas, bPersistent, -1.f, NextPathPointIndex);
}
ENavigationQueryResult::Type ANavigationData::CalcPathCost(const FVector& PathStart, const FVector& PathEnd, float& OutPathCost, FSharedConstNavQueryFilter QueryFilter, const UObject* Querier) const
{
FVector::FReal PathCost = OutPathCost;
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Public/NavigationData.h:744
Scope (from outer to inner):
file
class class ANavigationData : public AActor, public INavigationDataInterface
Source code excerpt:
//----------------------------------------------------------------------//
UE_DEPRECATED(5.0, "Use version that takes LifeTime instead.")
NAVIGATIONSYSTEM_API void DrawDebugPath(FNavigationPath* Path, const FColor PathColor, class UCanvas* Canvas, const bool bPersistent, const uint32 NextPathPointIndex) const;
NAVIGATIONSYSTEM_API void DrawDebugPath(FNavigationPath* Path, const FColor PathColor = FColor::White, class UCanvas* Canvas = nullptr, const bool bPersistent = true, const float LifeTime = -1.f, const uint32 NextPathPointIndex = 0) const;
FORCEINLINE bool IsDrawingEnabled() const { return bEnableDrawing; }
/** @return Total mem counted, including super calls. */
NAVIGATIONSYSTEM_API virtual uint32 LogMemUsed() const;