DefaultInputComponentClass

DefaultInputComponentClass

#Overview

name: DefaultInputComponentClass

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

#Summary

#Usage in the C++ source code

The purpose of DefaultInputComponentClass is to define the default class type for pawn input components in Unreal Engine 5. This setting variable is crucial for the input system, specifically for handling player input in game pawns.

The DefaultInputComponentClass is primarily used by the Engine module, particularly within the input and pawn-related subsystems. It’s referenced in the InputSettings class and the Pawn class, indicating its importance in configuring input behavior for game entities.

The value of this variable is set in the UInputSettings constructor, where it’s initialized to UInputComponent::StaticClass(). It can be modified through the SetDefaultInputComponentClass function in the InputSettings class.

This variable interacts with the OverrideInputComponentClass property in the Pawn class. If OverrideInputComponentClass is set, it takes precedence over DefaultInputComponentClass for that specific pawn.

Developers must be aware that changing this variable affects the default input component class for all pawns in the game. It’s important to ensure that any custom input component class derived from UInputComponent maintains compatibility with the existing input system.

Best practices when using this variable include:

  1. Only change it if you have a specific reason to use a custom input component class for all pawns.
  2. Ensure that any custom input component class is thoroughly tested and compatible with your game’s input requirements.
  3. Use the OverrideInputComponentClass in individual pawn classes when you need to specify a different input component class for specific pawn types.
  4. When setting a new default class, make sure it’s a valid subclass of UInputComponent to avoid runtime errors.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

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

Scope (from outer to inner):

file
class        class UInputSettings : public UObject

Source code excerpt:

	/** Default class type for pawn input components. */
	UPROPERTY(config, EditAnywhere, NoClear, Category = DefaultClasses)
	TSoftClassPtr<UInputComponent> DefaultInputComponentClass;

public:
	/** The default on-screen touch input interface for the game (can be null to disable the onscreen interface) */
	UPROPERTY(config, EditAnywhere, Category="Mobile", meta=(AllowedClasses="/Script/Engine.TouchInterface"))
	FSoftObjectPath DefaultTouchInterface;

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Classes/GameFramework/Pawn.h:553

Scope: file

Source code excerpt:

	FVector LastControlInputVector;

	/** If set, then this InputComponent class will be used instead of the Input Settings' DefaultInputComponentClass */
	UPROPERTY(EditDefaultsOnly, Category = "Pawn|Input")
	TSubclassOf<UInputComponent> OverrideInputComponentClass = nullptr;

public:
	/** Internal function meant for use only within Pawn or by a PawnMovementComponent. Adds movement input if not ignored, or if forced. */
	ENGINE_API void Internal_AddMovementInput(FVector WorldAccel, bool bForce = false);

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:33

Scope (from outer to inner):

file
function     UInputSettings::UInputSettings

Source code excerpt:

	, DefaultViewportMouseLockMode(EMouseLockMode::LockOnCapture)
	, DefaultPlayerInputClass(UPlayerInput::StaticClass())
	, DefaultInputComponentClass(UInputComponent::StaticClass())
{
	PlatformSettings.Initialize(UInputPlatformSettings::StaticClass());
}

void UInputSettings::RemoveInvalidKeys()
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:500

Scope (from outer to inner):

file
function     UClass* UInputSettings::GetDefaultInputComponentClass

Source code excerpt:

UClass* UInputSettings::GetDefaultInputComponentClass()
{
	TSoftClassPtr<UInputComponent> Class = UInputSettings::GetInputSettings()->DefaultInputComponentClass;
	ensureMsgf(Class.IsValid(), TEXT("Invalid InputComponent class in Input Settings. Manual reset required."));
	return Class.IsValid() ? Class.Get() : UInputComponent::StaticClass();
}

void UInputSettings::SetDefaultPlayerInputClass(TSubclassOf<UPlayerInput> NewDefaultPlayerInputClass)
{

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/UserInterface/InputSettings.cpp:519

Scope (from outer to inner):

file
function     void UInputSettings::SetDefaultInputComponentClass

Source code excerpt:

	{
		UInputSettings* InputSettings = Cast<UInputSettings>(UInputSettings::StaticClass()->GetDefaultObject());
		InputSettings->DefaultInputComponentClass = NewDefaultInputComponentClass;
	}
}

/////////////////////////////////////////////////////////////
// FHardwareDeviceIdentifier