To move an actor using Enhanced Input in Unreal Engine 5+, follow these steps:
✅ Step-by-Step Guide
1. Enable Enhanced Input Plugin
- Go to Edit > Plugins.
- Search for Enhanced Input and enable it.
- Restart the editor.
2. Create Input Mapping Context (IMC)
- Right-click in Content Browser → Input > Input Mapping Context.
- Name it something like
IMC_Player.
Add Mappings:
- MoveForward →
W (Scale: 1), S (Scale: -1)
- MoveRight →
D (Scale: 1), A (Scale: -1)
Use Vector2D or Axis1D depending on your setup.
3. Create Input Actions
- Right-click → Input > Input Action.
- Create:
IA_MoveForward (Axis1D)
IA_MoveRight (Axis1D)
Assign these to your IMC mappings.
4. Set Up Your Actor or Pawn
- Create a Blueprint or C++ class inheriting from
APawn or ACharacter.
- Add a Camera and SpringArm if needed.
- Add a FloatingPawnMovement or CharacterMovementComponent depending on your base class.
5. Bind Input in Blueprint (or C++)
🔹 Blueprint:
- Open your pawn/actor BP.
- Add Enhanced Input Component (if not already added).
- In Event Graph, use:
Setup Player Input Component node.
- Use
Add Mapping Context node:
- Input Context:
IMC_Player
- Priority: 0
- Bind
IA_MoveForward and IA_MoveRight to custom events.
- In those events, use
Add Movement Input or Add Actor Local Offset.
🔹 C++ (Example):
// In your Pawn or Character class header
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputMappingContext* DefaultMappingContext;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* MoveForwardAction;
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Input")
class UInputAction* MoveRightAction;
// In .cpp
void AMyPawn::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
if (UEnhancedInputComponent* EnhancedInputComponent = Cast<UEnhancedInputComponent>(PlayerInputComponent))
{
EnhancedInputComponent->BindAction(MoveForwardAction, ETriggerEvent::Triggered, this, &AMyPawn::MoveForward);
EnhancedInputComponent->BindAction(MoveRightAction, ETriggerEvent::Triggered, this, &AMyPawn::MoveRight);
}
if (APlayerController* PC = Cast<APlayerController>(GetController()))
{
if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PC->GetLocalPlayer()))
{
Subsystem->AddMappingContext(DefaultMappingContext, 0);
}
}
}
void AMyPawn::MoveForward(const FInputActionValue& Value)
{
float ForwardValue = Value.Get<float>();
AddMovementInput(GetActorForwardVector(), ForwardValue);
}
void AMyPawn::MoveRight(const FInputActionValue& Value)
{
float RightValue = Value.Get<float>();
AddMovementInput(GetActorRightVector(), RightValue);
}
6. Assign Assets in Blueprint Defaults
- In your pawn/character BP:
- Set
DefaultMappingContext to your IMC_Player.
- Set
MoveForwardAction and MoveRightAction to your IA_MoveForward and IA_MoveRight.
✅ Tips
- Use Character class if you want built-in movement like jumping, gravity, etc.
- Use Pawn class if you want full control (e.g., flying, custom physics).
- For multiplayer, ensure input is only handled on the client or authority as needed.
Let me know if you want a flying pawn setup or 2D movement version.