AActor::CreateInputComponent
#include "GameFramework/Actor.h"
Access: public
Specifiers: UFUNCTIONBlueprintCallablevirtual
Description
Creates the actor's InputComponent using the provided class. Called internally by EnableInput; override or call directly when you need to use a custom UInputComponent subclass (e.g. UEnhancedInputComponent).
Caveats & Gotchas
- • This was added in UE 5.1 alongside the Enhanced Input system. In 5.0 and earlier, input component creation was handled implicitly inside EnableInput without a public override point.
- • If you call EnableInput before calling CreateInputComponent with a custom class, the default UInputComponent will be created. Call CreateInputComponent first (or override it) if you need Enhanced Input bindings.
Signature
ENGINE_API virtual void CreateInputComponent(TSubclassOf<UInputComponent> InputComponentToCreate) Parameters
| Name | Type | Description | Default |
|---|---|---|---|
| InputComponentToCreate | TSubclassOf<UInputComponent> | The specific UInputComponent subclass to instantiate. | — |
Return Type
void Example
Override to use EnhancedInputComponent C++
// In actor subclass .cpp
void AMyActor::CreateInputComponent(TSubclassOf<UInputComponent> InputComponentToCreate)
{
Super::CreateInputComponent(UEnhancedInputComponent::StaticClass());
}
// Then bind Enhanced Input actions after EnableInput:
UEnhancedInputComponent* EIC = Cast<UEnhancedInputComponent>(InputComponent);
if (EIC && InteractAction)
{
EIC->BindAction(InteractAction, ETriggerEvent::Triggered, this, &AMyActor::Interact);
} See Also
Tags
Version History
Introduced in: 5.1
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
| 5.1 | stable | Added in 5.1 to support Enhanced Input component customization. |
Feedback
Was this helpful?