LoseSightRadius
LoseSightRadius
#Overview
name: LoseSightRadius
The value of this variable can be defined or overridden in .ini config files. 2
.ini config files referencing this setting variable.
It is referenced in 4
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of LoseSightRadius is to define the maximum distance at which an AI can still perceive a previously detected target in the Unreal Engine 5’s AI perception system. It is specifically used for the sight sense configuration in the AI perception module.
This setting variable is primarily used in the AI Module of Unreal Engine 5, specifically in the AI perception system and the sight sense configuration. It’s referenced in the MLAdapter plugin as well, which suggests it’s important for AI-related machine learning adaptations.
The value of this variable is typically set in the UAISenseConfig_Sight class, which is a configuration class for the sight sense. It can be set through the Unreal Editor in the properties panel of an AI perception component or programmatically in C++ code.
LoseSightRadius interacts with other variables in the sight configuration, such as SightRadius and PeripheralVisionAngleDegrees. It’s often used in conjunction with SightRadius to create a hysteresis effect in AI perception, where an AI needs to get closer to detect a target initially but can track it from further away once detected.
Developers should be aware that:
- LoseSightRadius is typically set larger than SightRadius to prevent rapid toggling of perception state.
- The value is in centimeters, as indicated by the meta data in the property declaration.
- It’s used in squared form in internal calculations for performance reasons.
Best practices when using this variable include:
- Always set LoseSightRadius greater than or equal to SightRadius.
- Consider the gameplay implications when setting this value - a larger value means AI can track targets from further away once detected.
- Use it in conjunction with other sight configuration properties for a balanced AI perception system.
- When modifying it at runtime, ensure to update the AI perception component accordingly.
- Be mindful of performance implications when setting very large values, as it can increase the number of perception checks.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseGame.ini:189, section: [/Script/AIModule.AIPerceptionComponent]
- INI Section:
/Script/AIModule.AIPerceptionComponent
- Raw value:
3500
- Is Array:
False
Location: <Workspace>/Engine/Config/BaseGame.ini:203, section: [/Script/AIModule.AISenseConfig_Sight]
- INI Section:
/Script/AIModule.AISenseConfig_Sight
- Raw value:
3500
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Private/Sensors/MLAdapterSensor_AIPerception.cpp:117
Scope (from outer to inner):
file
function void UMLAdapterSensor_AIPerception::OnAvatarSet
Source code excerpt:
check(SightConfig);
SightConfig->SightRadius = 50000;
SightConfig->LoseSightRadius = 53000;
SightConfig->PeripheralVisionAngleDegrees = PeripheralVisionAngleDegrees;
SightConfig->AutoSuccessRangeFromLastSeenLocation = FAISystem::InvalidRange;
SightConfig->SetMaxAge(MaxStimulusAge);
PerceptionComponent->ConfigureSense(*SightConfig);
PerceptionComponent->RegisterComponent();
}
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Classes/Perception/AISenseConfig_Sight.h:29
Scope (from outer to inner):
file
class class UAISenseConfig_Sight : public UAISenseConfig
Source code excerpt:
/** Maximum sight distance to see target that has been already seen. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Sense", config, meta = (UIMin = 0.0, ClampMin = 0.0, Units="Centimeters"))
float LoseSightRadius;
/** How far to the side AI can see, in degrees. Use SetPeripheralVisionAngle to change the value at runtime.
* The value represents the angle measured in relation to the forward vector, not the whole range. */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Sense", config, meta=(UIMin = 0.0, ClampMin = 0.0, UIMax = 180.0, ClampMax = 180.0, DisplayName="Peripheral Vision Half Angle", Units="Degrees"))
float PeripheralVisionAngleDegrees;
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Perception/AISense.cpp:219
Scope (from outer to inner):
file
function void UAISenseConfig_Sight::DescribeSelfToGameplayDebugger
Source code excerpt:
*GetDebugColor().ToString(), *DescribeColorHelper(GetDebugColor()),
*SightRangeColor.ToString(), SightRadius, *DescribeColorHelper(SightRangeColor),
*LoseSightRangeColor.ToString(), LoseSightRadius, *DescribeColorHelper(LoseSightRangeColor))
);
const AActor* BodyActor = PerceptionComponent->GetBodyActor();
if (BodyActor != nullptr)
{
FVector BodyLocation, BodyFacing;
PerceptionComponent->GetLocationAndDirection(BodyLocation, BodyFacing);
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeCylinder(BodyLocation, LoseSightRadius, 25.0f, LoseSightRangeColor));
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeCylinder(BodyLocation, SightRadius, 25.0f, SightRangeColor));
const float SightPieLength = FMath::Max(LoseSightRadius, SightRadius) + PointOfViewBackwardOffset;
const FVector RootLocation = BodyLocation - (BodyFacing * PointOfViewBackwardOffset);
const FVector LeftDirection = BodyFacing.RotateAngleAxis(PeripheralVisionAngleDegrees, FVector::UpVector);
const FVector RightDirection = BodyFacing.RotateAngleAxis(-PeripheralVisionAngleDegrees, FVector::UpVector);
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeSegment(RootLocation + (BodyFacing * NearClippingRadius), RootLocation + (BodyFacing * SightPieLength), SightRangeColor));
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeSegment(RootLocation + (LeftDirection * NearClippingRadius), RootLocation + (LeftDirection * SightPieLength), SightRangeColor));
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeSegment(RootLocation + (RightDirection * NearClippingRadius), RootLocation + (RightDirection * SightPieLength), SightRangeColor));
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Perception/AISense_Sight.cpp:113
Scope (from outer to inner):
file
function UAISense_Sight::FDigestedSightProperties::FDigestedSightProperties
Source code excerpt:
{
SightRadiusSq = FMath::Square(SenseConfig.SightRadius + SenseConfig.PointOfViewBackwardOffset);
LoseSightRadiusSq = FMath::Square(SenseConfig.LoseSightRadius + SenseConfig.PointOfViewBackwardOffset);
PointOfViewBackwardOffset = SenseConfig.PointOfViewBackwardOffset;
NearClippingRadiusSq = FMath::Square(SenseConfig.NearClippingRadius);
PeripheralVisionAngleCos = FMath::Cos(FMath::Clamp(FMath::DegreesToRadians(SenseConfig.PeripheralVisionAngleDegrees), 0.f, PI));
AffiliationFlags = SenseConfig.DetectionByAffiliation.GetAsFlags();
// keep the special value of FAISystem::InvalidRange (-1.f) if it's set.
AutoSuccessRangeSqFromLastSeenLocation = (SenseConfig.AutoSuccessRangeFromLastSeenLocation == FAISystem::InvalidRange) ? FAISystem::InvalidRange : FMath::Square(SenseConfig.AutoSuccessRangeFromLastSeenLocation);