CameraSpeed

CameraSpeed

#Overview

name: CameraSpeed

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

#Summary

#Usage in the C++ source code

The purpose of CameraSpeed is to control the movement speed of the camera in Unreal Engine’s viewport and editor environments. It is primarily used in the rendering and viewport systems to adjust how quickly the camera moves through the scene.

This setting variable is primarily relied upon by the UnrealEd module, specifically within the editor viewport and camera movement systems. It’s also used in various plugins such as ChaosClothAssetEditor, GeometryMode, and DisplayClusterLightCardEditor.

The value of this variable is typically set in the ULevelEditorViewportSettings class, which is a configuration class for editor viewport settings. It can be modified through the editor interface or programmatically.

CameraSpeed often interacts with other variables such as CameraSpeedScalar, which is used to further adjust the camera movement range. It’s also affected by input modifiers like the Shift key for boosting speed.

Developers should be aware that:

  1. CameraSpeed is clamped between 1 and 8 in the ULevelEditorViewportSettings class.
  2. The actual camera movement is often a result of CameraSpeed combined with other factors like CameraSpeedScalar and FlightCameraSpeedScale.
  3. Different viewport types (perspective vs. orthographic) may handle CameraSpeed differently.

Best practices when using this variable include:

  1. Consider the scale of your scene when adjusting CameraSpeed to ensure comfortable navigation.
  2. Use the CameraSpeedScalar in conjunction with CameraSpeed for fine-tuning camera movement.
  3. Be mindful of how CameraSpeed affects different camera movement modes (e.g., flying, orbiting) and adjust accordingly.
  4. When programmatically modifying CameraSpeed, ensure it remains within the clamped range (1-8) to maintain expected behavior.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/ChaosClothAssetEditor/Source/ChaosClothAssetEditor/Private/ChaosClothAsset/SClothEditorViewportToolBarBase.cpp:162

Scope (from outer to inner):

file
function     FText SChaosClothAssetEditorViewportToolBarBase::GetCameraSpeedLabel

Source code excerpt:

FText SChaosClothAssetEditorViewportToolBarBase::GetCameraSpeedLabel() const
{
	const float CameraSpeed = GetViewportClient().GetCameraSpeed();
	FNumberFormattingOptions FormattingOptions = FNumberFormattingOptions::DefaultNoGrouping();
	FormattingOptions.MaximumFractionalDigits = CameraSpeed > 1 ? 1 : 3;
	return FText::AsNumber(CameraSpeed, &FormattingOptions);
}

float SChaosClothAssetEditorViewportToolBarBase::GetCamSpeedSliderPosition() const
{
	return (GetViewportClient().GetCameraSpeedSetting() - 1) / ((float)FEditorViewportClient::MaxCameraSpeeds - 1);
}

#Loc: <Workspace>/Engine/Plugins/Editor/GeometryMode/Source/GeometryMode/Private/GeometryModifiers.cpp:642

Scope (from outer to inner):

file
function     bool UGeomModifier_Edit::InputDelta

Source code excerpt:

		if( !InViewportClient->IsOrtho() || !(InViewport->KeyState(EKeys::LeftMouseButton) && InViewport->KeyState(EKeys::RightMouseButton)) )
		{
			const float CameraSpeed = InViewportClient->GetCameraSpeed();
			CameraDelta *= CameraSpeed;
		}

		InViewportClient->MoveViewportCamera( CameraDelta, InRot );
	}

	EndTrans();

#Loc: <Workspace>/Engine/Plugins/Experimental/Mutable/Source/CustomizableObjectEditor/Private/MuCOE/CustomizableObjectEditorViewportClient.cpp:76

Scope (from outer to inner):

file
function     FCustomizableObjectEditorViewportClient::FCustomizableObjectEditorViewportClient

Source code excerpt:

	bSetOrbitalOnPerspectiveMode = true;

	const int32 CameraSpeed = 3;
	SetCameraSpeedSetting(CameraSpeed);

	bShowBones = false;

	bReferenceMeshMissingWarningMessageVisible = false;

	DrawHelper.bDrawPivot = false;

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayClusterLightCardEditor/Private/Viewport/DisplayClusterLightCardEditorViewportClient.cpp:133

Scope (from outer to inner):

file
function     FDisplayClusterLightCardEditorViewportClient::FDisplayClusterLightCardEditorViewportClient

Source code excerpt:

		static_cast<ELevelViewportType>(Settings->RenderViewportType));

	const int32 CameraSpeed = 3;
	SetCameraSpeedSetting(CameraSpeed);

	IDisplayClusterLightCardExtenderModule& LightCardExtenderModule = IDisplayClusterLightCardExtenderModule::Get();
	LightCardExtenderModule.GetOnSequencerTimeChanged().AddRaw(this, &FDisplayClusterLightCardEditorViewportClient::OnSequencerTimeChanged);
}

FDisplayClusterLightCardEditorViewportClient::~FDisplayClusterLightCardEditorViewportClient()

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

Scope (from outer to inner):

file
class        class ULevelEditorViewportSettings : public UObject

Source code excerpt:

	/** How fast the perspective camera moves when flying through the world. */
	UPROPERTY(config, meta=(UIMin = "1", UIMax = "8", ClampMin="1", ClampMax="8"))
	int32 CameraSpeed;

	/** 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. */

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

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;

		// Update the camera's position, rotation and FOV
		float EditorMovementDeltaUpperBound = 1.0f;	// Never "teleport" the camera further than a reasonable amount after a large quantum

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

Scope (from outer to inner):

file
function     void FEditorViewportClient::PeformDefaultCameraMovement

Source code excerpt:

			if (!IsOrtho())
			{
				const float CameraSpeed = GetCameraSpeed();
				Drag *= CameraSpeed;
			}
			MoveViewportCamera(Drag, Rot);

			const bool LeftMouseButtonDown = Viewport->KeyState(EKeys::LeftMouseButton);
			const bool MiddleMouseButtonDown = Viewport->KeyState(EKeys::MiddleMouseButton);
			const bool RightMouseButtonDown = Viewport->KeyState(EKeys::RightMouseButton);

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

Scope (from outer to inner):

file
function     void FEditorViewportClient::InputAxisForOrbit

Source code excerpt:

			const bool bInvert = GetDefault<ULevelEditorViewportSettings>()->bInvertMiddleMousePan;

			const float CameraSpeed = GetCameraSpeed();
			Drag *= CameraSpeed * CameraSpeedDistanceScale;

			FVector DeltaLocation = bInvert ? FVector(Drag.X, 0, -Drag.Z ) : FVector(-Drag.X, 0, Drag.Z);

			FVector LookAt = ViewTransform.GetLookAt();

			FMatrix RotMat =

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

Scope (from outer to inner):

file
function     void FEditorViewportClient::InputAxisForOrbit

Source code excerpt:

			FMatrix OrbitMatrix = ViewTransform.ComputeOrbitMatrix().InverseFast();

			const float CameraSpeed = GetCameraSpeed();
			Drag *= CameraSpeed * CameraSpeedDistanceScale;

			FVector DeltaLocation = bInvertY ? FVector(0, Drag.X + Drag.Y, 0) : FVector(0, Drag.X+ -Drag.Y, 0);

			FVector LookAt = ViewTransform.GetLookAt();

			// Orient the delta down the view direction towards the look at

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

Scope (from outer to inner):

file
function     void FEditorViewportClient::OnDollyPerspectiveCamera

Source code excerpt:

	}

	const float CameraSpeed = GetCameraSpeed(GetDefault<ULevelEditorViewportSettings>()->MouseScrollCameraSpeed);
	Drag *= CameraSpeed * 32.f;

	const bool bDollyCamera = true;
	MoveViewportCamera( Drag, FRotator::ZeroRotator, bDollyCamera );
	Invalidate( true, true );

	FEditorDelegates::OnDollyPerspectiveCamera.Broadcast(Drag, ViewIndex);

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

Scope (from outer to inner):

file
function     int32 FLevelEditorViewportClient::GetCameraSpeedSetting

Source code excerpt:

int32 FLevelEditorViewportClient::GetCameraSpeedSetting() const
{
	return GetDefault<ULevelEditorViewportSettings>()->CameraSpeed;
}

void FLevelEditorViewportClient::SetCameraSpeedSetting(int32 SpeedSetting)
{
	GetMutableDefault<ULevelEditorViewportSettings>()->CameraSpeed = SpeedSetting;
}

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/STransformViewportToolbar.cpp:603

Scope (from outer to inner):

file
function     FText STransformViewportToolBar::GetCameraSpeedLabel

Source code excerpt:

	if (ViewportPin.IsValid() && ViewportPin->GetViewportClient().IsValid())
	{
		float CameraSpeed = ViewportPin->GetViewportClient()->GetCameraSpeed();
		FNumberFormattingOptions FormattingOptions = FNumberFormattingOptions::DefaultNoGrouping();
		FormattingOptions.MaximumFractionalDigits = CameraSpeed > 1 ? 1 : 3;
		return FText::AsNumber(CameraSpeed, &FormattingOptions);
	}

	return FText();
}	

float STransformViewportToolBar::GetCamSpeedSliderPosition() const

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/UnrealEdSrv.cpp:3100

Scope (from outer to inner):

file
function     bool UUnrealEdEngine::Exec_Mode

Source code excerpt:

		{
			NewCameraSpeed = FMath::Clamp<int32>(NewCameraSpeed, 1, FLevelEditorViewportClient::MaxCameraSpeeds);
			GetMutableDefault<ULevelEditorViewportSettings>()->CameraSpeed = NewCameraSpeed;
		}
	}

	FParse::Value( Str, TEXT("SNAPDIST="), GetMutableDefault<ULevelEditorViewportSettings>()->SnapDistance );
	
	//

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameViewportClient.cpp:208

Scope (from outer to inner):

file
function     void UGameViewportClient::UpdateCsvCameraStats

Source code excerpt:

			{
				FVector Velocity = Diff / float(DeltaT);
				float CameraSpeed = Velocity.Size();
				float CameraSpeed2D = Velocity.Size2D();

				FCsvProfiler::RecordCustomStat("Speed", CsvData.CategoryIndex, CameraSpeed, ECsvCustomStatOp::Set);
				FCsvProfiler::RecordCustomStat("Speed2D", CsvData.CategoryIndex, CameraSpeed2D, ECsvCustomStatOp::Set);
			}

#if !UE_BUILD_SHIPPING
			FVector ForwardVec = SceneView->ViewMatrices.GetOverriddenTranslatedViewMatrix().GetColumn(2);
			FVector UpVec = SceneView->ViewMatrices.GetOverriddenTranslatedViewMatrix().GetColumn(1);