FOVScale

FOVScale

#Overview

name: FOVScale

The value of this variable can be defined or overridden in .ini config files. 2 .ini config files referencing this setting variable.

It is referenced in 9 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of FOVScale is to adjust the sensitivity of input actions based on the player’s field of view (FOV) in the game. This variable is primarily used for scaling input sensitivity, particularly for aiming and camera control.

FOVScale is used in several Unreal Engine subsystems and modules, including:

  1. Enhanced Input Plugin
  2. DisplayClusterScenePreview Plugin
  3. Engine’s Input System
  4. ShooterCore Runtime (in the Lyra project)

The value of this variable is typically set in the InputSettings class, which is part of the Engine’s core input system. It can be configured through the project settings or modified at runtime.

FOVScale interacts with other variables such as the player’s camera FOV angle and input sensitivity settings. It’s often used in calculations to adjust input values based on the current FOV.

Developers should be aware that:

  1. FOVScale affects the feel of input, especially for aiming and camera movement.
  2. It’s used differently for gamepad and mouse/keyboard input in some implementations.
  3. Changes to this value can significantly impact player experience, particularly in first-person or third-person games.

Best practices when using this variable include:

  1. Carefully test different FOVScale values to ensure a consistent feel across various FOV settings.
  2. Consider providing options for players to adjust this value if your game supports FOV changes.
  3. Be mindful of how FOVScale interacts with other input modifiers and sensitivity settings.
  4. Implement different scaling logic for different input types (gamepad vs. mouse) if necessary.
  5. Use this in conjunction with other input modifiers to create a smooth and responsive input experience across different FOV settings.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseInput.ini:7, section: [/Script/Engine.InputSettings]

Location: <Workspace>/Projects/Lyra/Config/DefaultInput.ini:29, section: [/Script/Engine.InputSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Private/InputModifiers.cpp:308

Scope (from outer to inner):

file
function     FInputActionValue UInputModifierFOVScaling::ModifyRaw_Implementation

Source code excerpt:


	const float FOVAngle = PC->PlayerCameraManager ? PC->PlayerCameraManager->GetFOVAngle() : 1.f;
	float Scale = FOVScale;

	switch(FOVScalingType)
	{
	case EFOVScalingType::Standard:
		// TODO: Fortnite falls back to old style FOV scaling for mouse input. Presumably for back compat, but this needs checking.
		if (PC->PlayerCameraManager)

#Loc: <Workspace>/Engine/Plugins/EnhancedInput/Source/EnhancedInput/Public/InputModifiers.h:304

Scope (from outer to inner):

file
class        class UInputModifierFOVScaling : public UInputModifier

Source code excerpt:

	// Extra scalar applied on top of basic FOV scaling.
	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Category = Settings, Config)
	float FOVScale = 1.f;

	UPROPERTY(EditInstanceOnly, BlueprintReadWrite, Category = Settings, Config)
	EFOVScalingType FOVScalingType = EFOVScalingType::Standard;	// TODO: UE4_BackCompat by default?

protected:
	virtual FInputActionValue ModifyRaw_Implementation(const UEnhancedPlayerInput* PlayerInput, FInputActionValue CurrentValue, float DeltaTime) override;

#Loc: <Workspace>/Engine/Plugins/Runtime/nDisplay/Source/DisplayClusterScenePreview/Private/DisplayClusterLightCardEditorHelper.cpp:663

Scope (from outer to inner):

file
function     void FDisplayClusterLightCardEditorHelper::GetSceneViewInitOptions

Source code excerpt:

		const float ZOffset = UE_OLD_HALF_WORLD_MAX;

		const float FOVScale = FMath::Tan(HalfFOV) / InDPIScale;

		const float OrthoWidth = 0.5f * FOVScale * ViewportSize.X;
		const float OrthoHeight = 0.5f * FOVScale * ViewportSize.Y;

		if ((bool)ERHIZBuffer::IsInverted)
		{
			OutViewInitOptions.ProjectionMatrix = FReversedZOrthoMatrix(
				OrthoWidth,
				OrthoHeight,

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/InputSettings.h:149

Scope (from outer to inner):

file
class        class UInputSettings : public UObject

Source code excerpt:

	// The scaling value to multiply the field of view by
	UPROPERTY(config, EditAnywhere, Category="MouseProperties", AdvancedDisplay, meta=(editcondition="bEnableFOVScaling"))
	float FOVScale;

	/** If a key is pressed twice in this amount of time it is considered a "double click" */
	UPROPERTY(config, EditAnywhere, Category="MouseProperties", AdvancedDisplay)
	float DoubleClickTime;

private:

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/PlayerInput.cpp:2029

Scope (from outer to inner):

file
function     float UPlayerInput::MassageAxisInput

Source code excerpt:

		// Take FOV into account (lower FOV == less sensitivity).
		APlayerController const* const PlayerController = GetOuterAPlayerController();
		float const FOVScale = (DefaultInputSettings->bEnableFOVScaling && PlayerController && PlayerController->PlayerCameraManager) ? (DefaultInputSettings->FOVScale*PlayerController->PlayerCameraManager->GetFOVAngle()) : 1.0f;
		NewVal *= FOVScale;

		// debug
		if (Key == EKeys::MouseX)
		{
			DebugUnSmoothedMouseX += NewVal * DebugSmoothedMouseSensitivity;
		}

#Loc: <Workspace>/Projects/Lyra/Plugins/GameFeatures/ShooterCore/Source/ShooterCoreRuntime/Private/Input/AimAssistInputModifier.cpp:687

Scope (from outer to inner):

file
function     FRotator UAimAssistInputModifier::UpdateRotationalVelocity

Source code excerpt:

		// Clamp the maximum amount of pull rotation to prevent it from yanking the player's view too much.
		// The clamped rate is scaled so it feels the same regardless of field of view.
		const float FOVScale = UAimAssistTargetManagerComponent::GetFOVScale(PC, ECommonInputType::Gamepad);
		const float PullMaxRotationRate = (Settings.PullMaxRotationRate.GetValue() * FOVScale);
		if (PullMaxRotationRate > 0.0f)
		{
			const float PullMaxRotation = (PullMaxRotationRate * DeltaTime);

			PullRotation.Yaw = FMath::Clamp(PullRotation.Yaw, -PullMaxRotation, PullMaxRotation);
			PullRotation.Pitch = FMath::Clamp(PullRotation.Pitch, -PullMaxRotation, PullMaxRotation);

#Loc: <Workspace>/Projects/Lyra/Plugins/GameFeatures/ShooterCore/Source/ShooterCoreRuntime/Private/Input/AimAssistInputModifier.cpp:730

Scope (from outer to inner):

file
function     FRotator UAimAssistInputModifier::UpdateRotationalVelocity

Source code excerpt:

		// Clamp the minimum amount of slow to prevent it from feeling sluggish on low sensitivity settings.
		// The clamped rate is scaled so it feels the same regardless of field of view.
		const float FOVScale = UAimAssistTargetManagerComponent::GetFOVScale(PC, ECommonInputType::Gamepad);
		const float SlowMinRotationRate = (Settings.SlowMinRotationRate.GetValue() * FOVScale);
		if (SlowMinRotationRate > 0.0f)
		{
			SlowRates.Yaw = FMath::Max(SlowRates.Yaw, SlowMinRotationRate);
			SlowRates.Pitch = FMath::Max(SlowRates.Pitch, SlowMinRotationRate);
		}

#Loc: <Workspace>/Projects/Lyra/Plugins/GameFeatures/ShooterCore/Source/ShooterCoreRuntime/Private/Input/AimAssistTargetManagerComponent.cpp:107

Scope (from outer to inner):

file
function     void UAimAssistTargetManagerComponent::GetVisibleTargets

Source code excerpt:

	const FVector ViewForward = OwnerData.ViewTransform.GetUnitAxis(EAxis::X);

	const float FOVScale = GetFOVScale(PC, ECommonInputType::Gamepad);
	const float InvFieldOfViewScale = (FOVScale > 0.0f) ? (1.0f / FOVScale) : 1.0f;
	const float TargetRange = (Settings.TargetRange.GetValue() * InvFieldOfViewScale);

	// Use the field of view to scale the reticle projection.  This maintains the same reticle size regardless of field of view.
	const float ReticleDepth = (Settings.ReticleDepth * InvFieldOfViewScale);

	// Calculate the bounds of this reticle in screen space

#Loc: <Workspace>/Projects/Lyra/Plugins/GameFeatures/ShooterCore/Source/ShooterCoreRuntime/Private/Input/AimAssistTargetManagerComponent.cpp:372

Scope (from outer to inner):

file
function     float UAimAssistTargetManagerComponent::GetFOVScale

Source code excerpt:

		}
		case ECommonInputType::MouseAndKeyboard:
			FovScale = (DefaultInputSettings->FOVScale * FOVAngle);
			break;
		default:
			ensure(false);
			break;
		}
	}