g.DebugCameraTraceComplex
g.DebugCameraTraceComplex
#Overview
name: g.DebugCameraTraceComplex
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
Whether DebugCamera should use complex or simple collision for the line trace.\n1: complex collision, 0: simple collision
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of g.DebugCameraTraceComplex is to control the type of collision detection used by the Debug Camera in Unreal Engine 5. It determines whether the Debug Camera should use complex or simple collision for line tracing.
This setting variable is primarily used in the Engine module, specifically within the Debug Camera system. It’s referenced in the DebugCameraHUD.cpp file, which is part of the Engine’s runtime.
The value of this variable is set through a console variable (CVar) system. It’s defined as a TAutoConsoleVariable with an initial value of 1, meaning it defaults to using complex collision.
The associated variable CVarDebugCameraTraceComplex interacts directly with g.DebugCameraTraceComplex. They share the same value and purpose.
Developers must be aware that this variable only affects debug builds. It’s wrapped in preprocessor conditionals that exclude it from shipping or test builds. This means any changes to this variable will not affect final released versions of the game.
Best practices when using this variable include:
- Use it primarily for debugging and testing collision scenarios.
- Be aware of the performance implications: complex collision is more accurate but computationally expensive compared to simple collision.
- Consider setting it to 0 (simple collision) if you’re experiencing performance issues during debugging.
- Remember that changes to this variable won’t affect shipping builds, so don’t rely on it for gameplay-critical features.
Regarding the associated variable CVarDebugCameraTraceComplex:
It’s an instance of TAutoConsoleVariable
The value is retrieved using the GetValueOnGameThread() method, which ensures thread-safe access to the variable’s value. The result is then used to set the bTraceComplex flag, which determines the collision complexity in the subsequent line trace operation.
Developers should be aware that changes to CVarDebugCameraTraceComplex will immediately affect the behavior of the Debug Camera’s line tracing. This can be useful for real-time debugging and testing different collision scenarios without recompiling the game.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DebugCameraHUD.cpp:21
Scope: file
Source code excerpt:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
static TAutoConsoleVariable<int32> CVarDebugCameraTraceComplex(
TEXT("g.DebugCameraTraceComplex"),
1,
TEXT("Whether DebugCamera should use complex or simple collision for the line trace.\n")
TEXT("1: complex collision, 0: simple collision"),
ECVF_Cheat);
#endif
// ------------------
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DebugCameraHUD.cpp:131
Scope (from outer to inner):
file
function void ADebugCameraHUD::PostRender
Source code excerpt:
}
#endif
const TCHAR* CVarComplexName = TEXT("g.DebugCameraTraceComplex");
bool bTraceComplex = true;
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
bTraceComplex = CVarDebugCameraTraceComplex.GetValueOnGameThread() != 0;
#endif
#Associated Variable and Callsites
This variable is associated with another variable named CVarDebugCameraTraceComplex
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DebugCameraHUD.cpp:20
Scope: file
Source code excerpt:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
static TAutoConsoleVariable<int32> CVarDebugCameraTraceComplex(
TEXT("g.DebugCameraTraceComplex"),
1,
TEXT("Whether DebugCamera should use complex or simple collision for the line trace.\n")
TEXT("1: complex collision, 0: simple collision"),
ECVF_Cheat);
#endif
#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/DebugCameraHUD.cpp:135
Scope (from outer to inner):
file
function void ADebugCameraHUD::PostRender
Source code excerpt:
#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
bTraceComplex = CVarDebugCameraTraceComplex.GetValueOnGameThread() != 0;
#endif
FCollisionQueryParams TraceParams(NAME_None, FCollisionQueryParams::GetUnknownStatId(), bTraceComplex, this);
TraceParams.bReturnPhysicalMaterial = true;
FHitResult Hit;
bool bHit = GetWorld()->LineTraceSingleByChannel(Hit, CamLoc, CamRot.Vector() * 100000.f + CamLoc, ECC_Visibility, TraceParams);