PeripheralVisionAngleDegrees
PeripheralVisionAngleDegrees
#Overview
name: PeripheralVisionAngleDegrees
The value of this variable can be defined or overridden in .ini config files. 1
.ini config file referencing this setting variable.
It is referenced in 7
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of PeripheralVisionAngleDegrees is to define the angle of peripheral vision for AI perception in Unreal Engine 5. It is used to determine the field of view for AI characters or sensors when detecting other entities in the game world.
This setting variable is primarily used in the AI Module and the MLAdapter plugin, which are part of Unreal Engine’s AI and machine learning systems. Specifically, it is utilized in the following subsystems:
- AI Perception System
- ML Adapter Sensor for AI Perception
The value of this variable is set in multiple places:
- In the UMLAdapterSensor_AIPerception constructor, it is initialized with a default value of 60.0 degrees.
- It can be configured through the Configure function of UMLAdapterSensor_AIPerception, allowing runtime adjustment.
- In the UAISenseConfig_Sight class, it is exposed as an editable property, allowing designers to set it in the Unreal Editor.
This variable interacts with other AI perception-related variables, such as SightRadius, LoseSightRadius, and MaxStimulusAge. It is used in calculations for determining if an object is within the AI’s field of view.
Developers should be aware of the following when using this variable:
- The value represents half of the total peripheral vision angle.
- It is measured in degrees and should be set between 0 and 180 degrees.
- The actual field of view is twice this value, centered on the AI’s forward vector.
Best practices for using this variable include:
- Set realistic values based on the type of AI or sensor being simulated.
- Consider performance implications when setting very large angles, as it may increase the number of objects that need to be processed.
- Use in conjunction with other sight configuration parameters for a well-balanced AI perception system.
- Utilize the editable properties in the Unreal Editor for easy tuning and iteration.
- When using the MLAdapter, consider exposing this parameter for machine learning algorithms to adjust dynamically.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseGame.ini:204, section: [/Script/AIModule.AISenseConfig_Sight]
- INI Section:
/Script/AIModule.AISenseConfig_Sight
- Raw value:
90
- 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:19
Scope (from outer to inner):
file
function UMLAdapterSensor_AIPerception::UMLAdapterSensor_AIPerception
Source code excerpt:
TargetsToSenseCount = 1;
TargetsSortType = ESortType::Distance;
PeripheralVisionAngleDegrees = 60.f;
MaxStimulusAge = 0.6f;
}
void UMLAdapterSensor_AIPerception::Configure(const TMap<FName, FString>& Params)
{
Super::Configure(Params);
#Loc: <Workspace>/Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Private/Sensors/MLAdapterSensor_AIPerception.cpp:52
Scope (from outer to inner):
file
function void UMLAdapterSensor_AIPerception::Configure
Source code excerpt:
if (PeripheralAngleValue != nullptr)
{
PeripheralVisionAngleDegrees = FMath::Max(FCString::Atof((TCHAR*)PeripheralAngleValue), 1.f);
}
const FName NAME_MaxAge = TEXT("max_age");
const FString* MaxAgeValue = Params.Find(NAME_MaxAge);
if (MaxAgeValue != nullptr)
{
#Loc: <Workspace>/Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Private/Sensors/MLAdapterSensor_AIPerception.cpp:118
Scope (from outer to inner):
file
function void UMLAdapterSensor_AIPerception::OnAvatarSet
Source code excerpt:
SightConfig->SightRadius = 50000;
SightConfig->LoseSightRadius = 53000;
SightConfig->PeripheralVisionAngleDegrees = PeripheralVisionAngleDegrees;
SightConfig->AutoSuccessRangeFromLastSeenLocation = FAISystem::InvalidRange;
SightConfig->SetMaxAge(MaxStimulusAge);
PerceptionComponent->ConfigureSense(*SightConfig);
PerceptionComponent->RegisterComponent();
}
}
#Loc: <Workspace>/Engine/Plugins/AI/MLAdapter/Source/MLAdapter/Public/Sensors/MLAdapterSensor_AIPerception.h:85
Scope (from outer to inner):
file
class class UMLAdapterSensor_AIPerception : public UMLAdapterSensor
Source code excerpt:
bool bSenseOnlyChanges = false;
float PeripheralVisionAngleDegrees;
float MaxStimulusAge;
uint16 TargetsToSenseCount;
ESortType TargetsSortType;
TArray<FTargetRecord> CachedTargets;
uint32 bVectorMode : 1;
};
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Classes/Perception/AISenseConfig_Sight.h:34
Scope (from outer to inner):
file
class class UAISenseConfig_Sight : public UAISenseConfig
Source code excerpt:
* 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;
/** */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Sense", config)
FAISenseAffiliationFilter DetectionByAffiliation;
/** If not an InvalidRange (which is the default), we will always be able to see the target that has already been seen if they are within this range of their last seen location. */
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Perception/AISense.cpp:233
Scope (from outer to inner):
file
function void UAISenseConfig_Sight::DescribeSelfToGameplayDebugger
Source code excerpt:
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));
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeSegment(RootLocation + (LeftDirection * NearClippingRadius), RootLocation + (BodyFacing * NearClippingRadius), SightRangeColor));
DebuggerCategory->AddShape(FGameplayDebuggerShape::MakeSegment(RootLocation + (BodyFacing * NearClippingRadius), RootLocation + (RightDirection * NearClippingRadius), SightRangeColor));
}
#Loc: <Workspace>/Engine/Source/Runtime/AIModule/Private/Perception/AISense_Sight.cpp:116
Scope (from outer to inner):
file
function UAISense_Sight::FDigestedSightProperties::FDigestedSightProperties
Source code excerpt:
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);
}
UAISense_Sight::FDigestedSightProperties::FDigestedSightProperties()