MouseSensitivty

MouseSensitivty

#Overview

name: MouseSensitivty

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 8 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of MouseSensitivty is to control the sensitivity of mouse movement when rotating the camera in the Unreal Engine editor viewport. This setting variable is primarily used for the viewport control system in the editor.

Based on the callsites, this setting variable is primarily used in the UnrealEd module, specifically in the editor viewport subsystem. It is referenced in the LevelEditorViewportSettings class and used in EditorViewportClient and MouseDeltaTracker.

The value of this variable is set in the ULevelEditorViewportSettings constructor with a default value of 0.2f. It can be modified through the editor settings interface, as indicated by the UPROPERTY macro with the EditAnywhere and config flags.

This variable interacts with mouse input delta values to calculate camera rotation and movement. It is used in conjunction with other viewport settings and input states to determine the final camera behavior.

Developers should be aware of the following when using this variable:

  1. The value is clamped between 0.01 and 1.0, as specified in the UPROPERTY meta data.
  2. It affects both orbit and free-look camera modes in the editor viewport.
  3. The variable name has a typo (MouseSensitivty instead of MouseSensitivity), which should be kept in mind when referencing it in code.

Best practices when using this variable include:

  1. Respecting the clamped range (0.01 to 1.0) when setting the value programmatically.
  2. Considering user preferences and providing a way for users to adjust this setting in the editor UI.
  3. Being mindful of how changes to this value might affect user experience across different viewport interactions.
  4. When using this variable in calculations, consider normalizing or scaling the input to ensure consistent behavior across different mouse sensitivities.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEditorPerProjectUserSettings.ini:336, section: [/Script/UnrealEd.LevelEditorViewportSettings]

#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:339

Scope (from outer to inner):

file
class        class ULevelEditorViewportSettings : public UObject

Source code excerpt:

	/** The sensitivity of mouse movement when rotating the camera. */
	UPROPERTY(EditAnywhere, config, Category=Controls, meta=(DisplayName="Mouse Sensitivity", ClampMin="0.01",ClampMax="1.0") )
	float MouseSensitivty;

	/** Camera movement notification toggle to switch back to the behavior that caused camera notifications to be sent during gizmo movement. */
	UPROPERTY(EditAnywhere, config, Category = Controls)
	uint32 bUseLegacyCameraMovementNotifications : 1;
	
	/** Whether or not to invert mouse on the y axis in free look mode */

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:4918

Scope (from outer to inner):

file
function     void FEditorViewportClient::ConvertMovementToDragRot

Source code excerpt:

				InDragDelta.Y = InDelta.Y * FMath::Sin( ViewRotation.Yaw * PI / 180.f );

				InRotDelta.Yaw = InDelta.X * ViewportSettings->MouseSensitivty;
			}
			else if( MiddleMouseButtonDown || bIsUsingTrackpad || ( ( LeftMouseButtonDown || bIsUsingTrackpad ) && RightMouseButtonDown ) )
			{
				// Pan left/right/up/down
				const bool bInvert = !bIsUsingTrackpad && MiddleMouseButtonDown && GetDefault<ULevelEditorViewportSettings>()->bInvertMiddleMousePan;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:4939

Scope (from outer to inner):

file
function     void FEditorViewportClient::ConvertMovementToDragRot

Source code excerpt:

				float Direction = bInvertY ? -1 : 1;

				InRotDelta.Yaw = InDelta.X * ViewportSettings->MouseSensitivty;
				InRotDelta.Pitch = InDelta.Y * ViewportSettings->MouseSensitivty * Direction;
			}
		}
		break;

	default:
		check(0);	// unknown viewport type

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:5004

Scope (from outer to inner):

file
function     void FEditorViewportClient::ConvertMovementToOrbitDragRot

Source code excerpt:


				// Change the viewing angle
				InRotDelta.Yaw = InDelta.X * ViewportSettings->MouseSensitivty;
				InRotDelta.Pitch = InDelta.Y * ViewportSettings->MouseSensitivty * Direction;
			}
			else if( IsOrbitPanMode( Viewport ) )
			{
				// Pan left/right/up/down
				InDragDelta.X = InDelta.X * -FMath::Sin( YawRadians );
				InDragDelta.Y = InDelta.X *  FMath::Cos( YawRadians );

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/EditorViewportClient.cpp:5414

Scope (from outer to inner):

file
function     void FEditorViewportClient::MoveViewportCamera

Source code excerpt:

				const FVector RotEuler = InRot.Euler();

				CameraUserImpulseData->RotateRollVelocityModifier += VelModRotSpeed * RotEuler.X / ViewportSettings->MouseSensitivty;
				CameraUserImpulseData->RotatePitchVelocityModifier += VelModRotSpeed * RotEuler.Y / ViewportSettings->MouseSensitivty;
				CameraUserImpulseData->RotateYawVelocityModifier += VelModRotSpeed * RotEuler.Z / ViewportSettings->MouseSensitivty;
			}
			else if (!bLockFlightCamera)
			{
				MoveViewportPerspectiveCamera( InDrag, InRot, bDollyCamera );
			}
		}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/MouseDeltaTracker.cpp:451

Scope (from outer to inner):

file
function     void FMouseDeltaTracker::AddDelta

Source code excerpt:

		if (bIsRotation)
		{
			Wk *= GetDefault<ULevelEditorViewportSettings>()->MouseSensitivty;
		}
		else if( WidgetMode == UE::Widget::WM_Scale && !GEditor->UsePercentageBasedScaling() )
		{
			const float ScaleSpeedMultipler = 0.01f;
			Wk *= ScaleSpeedMultipler;
		}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:947

Scope (from outer to inner):

file
function     ULevelEditorViewportSettings::ULevelEditorViewportSettings

Source code excerpt:

	bShowActorEditorContext = true;
	bAllowEditWidgetAxisDisplay = true;
	MouseSensitivty = .2f;
	bUseLegacyCameraMovementNotifications = false;
	// Set a default preview mesh
	PreviewMeshes.Add(FSoftObjectPath("/Engine/EditorMeshes/ColorCalibrator/SM_ColorCalibrator.SM_ColorCalibrator"));
	LastInViewportMenuLocation = FVector2D(EForceInit::ForceInitToZero);
}

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/Settings/SettingsClasses.cpp:961

Scope (from outer to inner):

file
function     void ULevelEditorViewportSettings::PostInitProperties

Source code excerpt:


	// Make sure the mouse sensitivity is not set below a valid value somehow. This can cause weird viewport interactions.
	MouseSensitivty = FMath::Max(MouseSensitivty, .01f);
}

void ULevelEditorViewportSettings::PostEditChangeProperty( struct FPropertyChangedEvent& PropertyChangedEvent )
{
	Super::PostEditChangeProperty(PropertyChangedEvent);