ActorSnapDistance
ActorSnapDistance
#Overview
name: ActorSnapDistance
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 3
C++ source files.
#Summary
#Usage in the C++ source code
The purpose of ActorSnapDistance is to define the global actor snap distance setting for the editor in Unreal Engine 5. This variable is used to control the snapping behavior of actors in the level editor viewport.
The ActorSnapDistance variable is primarily used by the UnrealEd module, specifically within the level editor viewport settings and snapping utilities. It is part of the ULevelEditorViewportSettings class, which is responsible for storing and managing various viewport-related settings.
The value of this variable is set in the ULevelEditorViewportSettings class, which is defined in the LevelEditorViewportSettings.h file. It is marked as a UPROPERTY with the ‘config’ specifier, indicating that its value can be saved and loaded from configuration files.
ActorSnapDistance interacts with other variables such as ActorSnapScale and SnapDistance. The ActorSnapScale is used to modify the effective snap distance, while SnapDistance appears to be a related setting, possibly for non-actor snapping.
Developers should be aware that:
- The actual snap distance used may be scaled by ActorSnapScale.
- There’s a mechanism to convert legacy ActorSnapScale values greater than 1.0 into equivalent ActorSnapDistance values.
- The effective snap distance is clamped to be non-negative.
Best practices when using this variable include:
- Ensure that the ActorSnapDistance is set to an appropriate value for the scale of your level to achieve precise actor placement.
- Consider the interaction between ActorSnapDistance and ActorSnapScale when adjusting snapping behavior.
- Be aware that changes to this variable will affect all actors in the editor, so it should be adjusted with care.
- Use the provided getter and setter functions (GetActorSnapDistance and SetActorSnapDistance) instead of modifying the variable directly to ensure proper scaling and clamping are applied.
#Setting Variables
#References In INI files
Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:425, section: [/Script/UnrealEd.LevelEditorViewportSettings]
- INI Section:
/Script/UnrealEd.LevelEditorViewportSettings
- Raw value:
100.0
- Is Array:
False
#References in C++ code
#Callsites
This variable is referenced in the following C++ source code:
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:469
Scope (from outer to inner):
file
class class ULevelEditorViewportSettings : public UObject
Source code excerpt:
/** Global actor snap distance setting for the editor */
UPROPERTY(config)
float ActorSnapDistance;
UPROPERTY(config)
bool bSnapVertices;
UPROPERTY(config)
float SnapDistance;
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/SnappingUtils.cpp:161
Scope (from outer to inner):
file
function float FEditorViewportSnapping::GetActorSnapDistance
Source code excerpt:
if (ViewportSettings->ActorSnapScale > 1.0f)
{
ViewportSettings->ActorSnapDistance *= ViewportSettings->ActorSnapScale;
ViewportSettings->ActorSnapScale = 1.0f;
ViewportSettings->PostEditChange();
}
if (bScalar)
{
#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/SnappingUtils.cpp:173
Scope (from outer to inner):
file
function float FEditorViewportSnapping::GetActorSnapDistance
Source code excerpt:
// Multiply by the max distance allowed to convert to range
return FMath::Max(0.0f, ViewportSettings->ActorSnapScale) * ViewportSettings->ActorSnapDistance;
}
void FEditorViewportSnapping::SetActorSnapDistance(float Distance)
{
ULevelEditorViewportSettings* ViewportSettings = GetMutableDefault<ULevelEditorViewportSettings>();
ViewportSettings->ActorSnapScale = Distance;