ai.NavCollisionAvailable
ai.NavCollisionAvailable
#Overview
name: ai.NavCollisionAvailable
This variable is created as a Console Variable (cvar).
- type:
Var
- help:
If set to 0 NavCollision won\'t be cooked and will be unavailable at runtime.\n
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ai.NavCollisionAvailable is to control the availability of NavCollision data in the Unreal Engine’s navigation system. This setting variable is primarily used for the AI and navigation subsystems within the engine.
The Unreal Engine’s NavigationSystem module relies on this setting variable. It is specifically used in the NavCollision component, which is part of the navigation system used for AI pathfinding and obstacle avoidance.
The value of this variable is set through a console variable (CVar) named CVarNavCollisionAvailable. It is initialized with a default value of 1, indicating that NavCollision is available by default.
The associated variable CVarNavCollisionAvailable directly interacts with ai.NavCollisionAvailable. They share the same value and purpose within the code.
Developers must be aware that setting this variable to 0 will prevent NavCollision from being cooked and make it unavailable at runtime. This can have significant implications for AI navigation in the game.
Best practices when using this variable include:
- Only disable NavCollision (by setting to 0) if you are certain that your game does not require it for any AI or navigation purposes.
- Be cautious when changing this value, as it affects the entire navigation system and could impact performance or gameplay.
- If you’re developing for a platform that requires cooked data, ensure this variable is set correctly before cooking your project.
Regarding the associated variable CVarNavCollisionAvailable:
The purpose of CVarNavCollisionAvailable is to provide a programmatic way to access and modify the ai.NavCollisionAvailable setting. It is implemented as a TAutoConsoleVariable, which allows it to be changed at runtime through console commands.
This variable is used directly in the NavCollision component of the NavigationSystem module. It’s checked in various functions to determine whether NavCollision data should be processed or used.
The value of CVarNavCollisionAvailable is set when the engine initializes, but it can be modified at runtime through console commands.
CVarNavCollisionAvailable interacts directly with ai.NavCollisionAvailable, effectively serving as its in-code representation.
Developers should be aware that changes to CVarNavCollisionAvailable will immediately affect the behavior of the navigation system. It’s also important to note that this variable has the ECVF_Scalability flag, indicating it can be used for performance scaling.
Best practices for using CVarNavCollisionAvailable include:
- Use it for debug purposes or performance optimization in shipping builds.
- Be cautious when modifying it at runtime, as it can significantly impact AI behavior.
- Consider platform-specific requirements when setting or modifying this variable, especially for platforms that require cooked data.
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavCollision.cpp:23
Scope: file
Source code excerpt:
static TAutoConsoleVariable<int32> CVarNavCollisionAvailable(
TEXT("ai.NavCollisionAvailable"),
1,
TEXT("If set to 0 NavCollision won't be cooked and will be unavailable at runtime.\n"),
/*ECVF_ReadOnly | */ECVF_Scalability);
#if ENABLE_COOK_STATS
namespace NavCollisionCookStats
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavCollision.cpp:623
Scope (from outer to inner):
file
function bool UNavCollision::NeedsLoadForTargetPlatform
Source code excerpt:
{
int32 CVarNavCollisionAvailableVal = 1;
if (DeviceProfile->GetConsolidatedCVarValue(TEXT("ai.NavCollisionAvailable"), CVarNavCollisionAvailableVal))
{
return CVarNavCollisionAvailableVal != 0;
}
}
#endif // WITH_EDITOR
#Associated Variable and Callsites
This variable is associated with another variable named CVarNavCollisionAvailable
. They share the same value. See the following C++ source code.
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavCollision.cpp:22
Scope: file
Source code excerpt:
#endif // WITH_EDITOR
static TAutoConsoleVariable<int32> CVarNavCollisionAvailable(
TEXT("ai.NavCollisionAvailable"),
1,
TEXT("If set to 0 NavCollision won't be cooked and will be unavailable at runtime.\n"),
/*ECVF_ReadOnly | */ECVF_Scalability);
#if ENABLE_COOK_STATS
#Loc: <Workspace>/Engine/Source/Runtime/NavigationSystem/Private/NavCollision.cpp:574
Scope (from outer to inner):
file
function FByteBulkData* UNavCollision::GetCookedData
Source code excerpt:
FByteBulkData* Result = &CookedFormatData.GetFormat(Format);
if (!bContainedData && CVarNavCollisionAvailable.GetValueOnAnyThread() != 0)
{
if (FPlatformProperties::RequiresCookedData())
{
UE_LOG(LogNavigation, Error, TEXT("Attempt to build nav collision data for %s when we are unable to. This platform requires cooked packages."), *GetPathName());
return nullptr;
}