CameraSpeedScalar

CameraSpeedScalar

#Overview

name: CameraSpeedScalar

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

#Summary

#Usage in the C++ source code

The purpose of CameraSpeedScalar is to adjust the speed of camera movement in Unreal Engine’s editor viewports. It acts as a multiplier for the base camera speed, allowing users to fine-tune the camera’s responsiveness to input.

This setting variable is primarily used in the editor’s viewport system, specifically within the FEditorViewportClient class. It is utilized by both the general editor viewport and specialized viewports like the animation editor (Persona).

The value of CameraSpeedScalar is typically set through user preferences or editor settings. In the case of the animation editor, it’s set via the UPersonaOptions class, which handles asset editor-specific configurations. For the level editor, it’s set in the ULevelEditorViewportSettings class.

CameraSpeedScalar interacts with other variables such as CameraSpeedSetting and FlightCameraSpeedScale to determine the final camera movement speed. It’s also affected by input modifiers like the Shift key for camera speed boosting.

Developers should be aware that this variable directly impacts the user experience in navigating 3D viewports. Setting it too high might make camera control feel too sensitive, while setting it too low could make navigation feel sluggish.

Best practices when using this variable include:

  1. Providing a user-friendly interface for adjusting this value in editor settings.
  2. Implementing proper clamping to prevent extreme values (e.g., FMath::Clamp(SpeedScalar, 1.0f, TNumericLimits ::Max())).
  3. Considering how it interacts with other speed modifiers to ensure a smooth and intuitive camera control experience.
  4. Potentially offering presets or adaptive settings based on the scale or type of the scene being edited.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Source/Editor/Persona/Private/AnimationEditorViewportClient.cpp:141

Scope (from outer to inner):

file
function     FAnimationViewportClient::FAnimationViewportClient

Source code excerpt:

	ViewFOV = FMath::Clamp<float>(ConfigOption->GetAssetEditorOptions(InAssetEditorToolkit->GetEditorName()).ViewportConfigs[ViewportIndex].ViewFOV, FOVMin, FOVMax);
	CameraSpeedSetting = ConfigOption->GetAssetEditorOptions(InAssetEditorToolkit->GetEditorName()).ViewportConfigs[ViewportIndex].CameraSpeedSetting;
	CameraSpeedScalar = ConfigOption->GetAssetEditorOptions(InAssetEditorToolkit->GetEditorName()).ViewportConfigs[ViewportIndex].CameraSpeedScalar;

	EngineShowFlags.SetSeparateTranslucency(true);
	EngineShowFlags.SetCompositeEditorPrimitives(true);

	EngineShowFlags.SetSelectionOutline(true);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Preferences/PersonaOptions.h:51

Scope: file

Source code excerpt:


	UPROPERTY(EditAnywhere, config, Category = "Viewport")
	float CameraSpeedScalar;

	/** Persisted camera follow mode for a viewport */
	UPROPERTY(config)
	EAnimationViewportCameraFollowMode CameraFollowMode;

	UPROPERTY(config)

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Preferences/PersonaOptions.h:64

Scope (from outer to inner):

file
function     FViewportConfigOptions

Source code excerpt:

		, ViewFOV(53.43f)
		, CameraSpeedSetting(4)
		, CameraSpeedScalar(1.0f)
		, CameraFollowMode(EAnimationViewportCameraFollowMode::None)
	{}

	void SetToDefault();
};

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Classes/Settings/LevelEditorViewportSettings.h:331

Scope (from outer to inner):

file
class        class ULevelEditorViewportSettings : public UObject

Source code excerpt:

	/** Scalar applied to perspective camera movement to increase movement range. */
	UPROPERTY(config, meta = (ClampMin = "1", UIMax = "128"))
	float CameraSpeedScalar;

	/** How fast the perspective camera moves through the world when using mouse scroll. */
	UPROPERTY(EditAnywhere, config, Category=Controls, meta=(UIMin = "1", UIMax = "8", ClampMin="1", ClampMax="8"))
	int32 MouseScrollCameraSpeed;

	/** The sensitivity of mouse movement when rotating the camera. */

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

Scope (from outer to inner):

file
function     float FEditorViewportClient::GetCameraSpeedScalar

Source code excerpt:

float FEditorViewportClient::GetCameraSpeedScalar() const
{
	return CameraSpeedScalar;
}

void FEditorViewportClient::SetCameraSpeedScalar(float SpeedScalar)
{
	CameraSpeedScalar = FMath::Clamp<float>(SpeedScalar, 1.0f, TNumericLimits <float>::Max());
}

void FEditorViewportClient::TakeOwnershipOfModeManager(TSharedPtr<FEditorModeTools>& ModeManagerPtr)
{
	ModeManagerPtr = ModeTools;
}

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

Scope (from outer to inner):

file
function     FEditorViewportClient::FEditorViewportClient

Source code excerpt:

	: bAllowCinematicControl(false)
	, CameraSpeedSetting(4)
	, CameraSpeedScalar(1.0f)
	, ImmersiveDelegate()
	, VisibilityDelegate()
	, Viewport(NULL)
	, ViewportType(LVT_Perspective)
	, ViewState()
	, StereoViewStates()

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

Scope (from outer to inner):

file
function     void FEditorViewportClient::UpdateCameraMovement

Source code excerpt:


		// We'll combine the regular camera speed scale (controlled by viewport toolbar setting) with
		// the flight camera speed scale (controlled by mouse wheel) and the CameraSpeedScalar (set in the transform viewport toolbar).
		const float CameraSpeed = GetCameraSpeed();
		const float CameraBoost = IsShiftPressed() ? 2.0f : 1.0f;
		const float FinalCameraSpeedScale = FlightCameraSpeedScale * CameraSpeed * GetCameraSpeedScalar() * CameraBoost;

		// Only allow FOV recoil if flight camera mode is currently inactive.
		const bool bAllowRecoilIfNoImpulse = !bUsingFlightInput;

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/LevelEditorViewport.cpp:5442

Scope (from outer to inner):

file
function     float FLevelEditorViewportClient::GetCameraSpeedScalar

Source code excerpt:

float FLevelEditorViewportClient::GetCameraSpeedScalar() const
{
	return GetDefault<ULevelEditorViewportSettings>()->CameraSpeedScalar;
}

void FLevelEditorViewportClient::SetCameraSpeedScalar(float SpeedScalar)
{	
	GetMutableDefault<ULevelEditorViewportSettings>()->CameraSpeedScalar = SpeedScalar;
}

bool FLevelEditorViewportClient::OverrideHighResScreenshotCaptureRegion(FIntRect& OutCaptureRegion)
{
	FSlateRect Rect;
	if (CalculateEditorConstrainedViewRect(Rect, Viewport, GetDPIScale()))

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PreferenceStubs.cpp:105

Scope (from outer to inner):

file
function     void FViewportConfigOptions::SetToDefault

Source code excerpt:

	ViewFOV = 53.43f;
	CameraSpeedSetting = 4;
	CameraSpeedScalar = 1.0f;
	CameraFollowMode = EAnimationViewportCameraFollowMode::None;
	CameraFollowBoneName = NAME_None;
}

void FAssetEditorOptions::SetViewportConfigsToDefault()
{

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/PreferenceStubs.cpp:228

Scope (from outer to inner):

file
function     void UPersonaOptions::SetCameraSpeedScalar

Source code excerpt:


	FAssetEditorOptions& Options = GetAssetEditorOptions(InContext);
	Options.ViewportConfigs[InViewportIndex].CameraSpeedScalar = InCameraSpeedScalar;
	SaveConfig();
}

void UPersonaOptions::SetViewCameraFollow( FName InContext, EAnimationViewportCameraFollowMode InCameraFollowMode, FName InCameraFollowBoneName, int32 InViewportIndex )
{
	check(InViewportIndex >= 0 && InViewportIndex < 4);

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Public/EditorViewportClient.h:1230

Scope (from outer to inner):

file
class        class FEditorViewportClient : public FCommonViewportClient, public FViewElementDrawer, public FGCObject

Source code excerpt:


	/** Camera speed scalar */
	float CameraSpeedScalar;

public:

	UNREALED_API void DrawBoundingBox(FBox &Box, FCanvas* InCanvas, const FSceneView* InView, const FViewport* InViewport, const FLinearColor& InColor, const bool bInDrawBracket, const FString &InLabelText) ;
	
	/**