gamedev-skills/awesome-gamedev-agent-skills / skills/unreal/unreal-enhanced-input
unreal-enhanced-input
VerifiedUnreal Engine 5 (UE 5.8) player input with Enhanced Input: Input Actions (IA_), Mapping Contexts (IMC_), ETriggerEvent bindings and remappable keys. Use when wiring move, look or fire, building a rebind menu, or input does nothing, stops after respawn or fires every frame. Not for engine-neutral input design (`input-systems`) or the Character class (`unreal-cpp-gameplay`).
| File | Kind | Size |
|---|---|---|
| SKILL.md | skill md | 8.0 KB |
| references/cpp-setup.md | markdown | 5.0 KB |
references/cpp-setup.md
View on GitHub# Enhanced Input — complete C++ Character (UE 5.8)
Depth for `unreal-enhanced-input`: a self-contained third-person Character that adds a mapping
context and binds move/look/jump. Verified against the Enhanced Input documentation.
Contents:
- Header
- Source (context added in `PawnClientRestart`, bindings, move and look handlers)
- Build.cs
- Asset setup checklist (editor)
- Runtime rebinding note (Enhanced Input User Settings)
## Header
```cpp
// MyCharacter.h
#pragma once
#include "CoreMinimal.h"
#include "GameFramework/Character.h"
#include "MyCharacter.generated.h"
class UInputMappingContext;
class UInputAction;
struct FInputActionValue;
UCLASS()
class MYGAME_API AMyCharacter : public ACharacter
{
GENERATED_BODY()
public:
AMyCharacter();
protected:
virtual void PawnClientRestart() override; // owning client, after possession
virtual void SetupPlayerInputComponent(UInputComponent* PlayerInputComponent) override;
// Assign these in the Blueprint subclass (IMC_/IA_ assets).
UPROPERTY(EditAnywhere, Category = "Input")
TObjectPtr<UInputMappingContext> DefaultMappingContext;
UPROPERTY(EditAnywhere, Category = "Input")
TObjectPtr<UInputAction> MoveAction;
UPROPERTY(EditAnywhere, Category = "Input")
TObjectPtr<UInputAction> LookAction;
UPROPERTY(EditAnywhere, Category = "Input")
TObjectPtr<UInputAction> JumpAction;
void Move(const FInputActionValue& Value);
void Look(const FInputActionValue& Value);
};
```
## Source
```cpp
// MyCharacter.cpp
#include "MyCharacter.h"
#include "EnhancedInputComponent.h"
#include "EnhancedInputSubsystems.h"
#include "InputActionValue.h"
AMyCharacter::AMyCharacter()
{
// (camera/spring-arm setup omitted; see the unreal-cpp-gameplay skill)
}
void AMyCharacter::PawnClientRestart()
{
Super::PawnClientRestart();
if (APlayerController* PC = Cast<APlayerController>(GetController()))
if (ULocalPlayer* LP = PC->GetLocalPlayer())
if (UEnhancedInputLocalPlayerSubsystem* Subsystem =
LP->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>())
Subsystem->AddMappingContext(DefaultMappingContext, 0);
}
void AMyCharacter::SetupPlayerInputComponent(UInputComponent* PlayerInputComponent)
{
Super::SetupPlayerInputComponent(PlayerInputComponent);
if (UEnhancedInputComponent* EIC = Cast<UEnhancedInputComponent>(PlayerInputComponent))
{
EIC->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AMyCharacter::Move);
EIC->BindAction(LookAction, ETriggerEvent::Triggered, this, &AMyCharacter::Look);
EIC->BindAction(JumpAction, ETriggerEvent::Started, this, &ACharacter::Jump);
EIC->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);
}
}
void AMyCharacter::Move(const FInputActionValue& Value)
{
const FVector2D Axis = Value.Get<FVector2D>();
if (Controller)
{
// Move relative to where the controller is facing (yaw only).
const FRotator Yaw(0, Controller->GetControlRotation().Yaw, 0);
AddMovementInput(FRotationMatrix(Yaw).GetUnitAxis(EAxis::X), Axis.Y);
AddMovementInput(FRotationMatrix(Yaw).GetUnitAxis(EAxis::Y), Axis.X);
}
}
void AMyCharacter::Look(const FInputActionValue& Value)
{
const FVector2D Axis = Value.Get<FVector2D>();
AddControllerYawInput(Axis.X);
AddControllerPitchInput(Axis.Y);
}
```
## Build.cs
```csharp
PublicDependencyModuleNames.AddRange(new string[]
{
"Core", "CoreUObject", "Engine", "InputCore", "EnhancedInput"
});
```
## Asset setup checklist (editor)
1. `IA_Move` — Value Type **Axis2D**; `IA_Look` — Axis2D; `IA_Jump` — **Digital (bool)**.
2. `IMC_Default` mappings:
- `IA_Move`: W (no modifier), S (**Negate**), and a **Swizzle Input Axis Values** on the
up/down keys so vertical maps to Y; A (**Negate**), D for X.
- `IA_Look`: Mouse XY (add **Negate** on Y if inverted); gamepad right stick.
- `IA_Jump`: Space Bar / gamepad face button.
3. In the Blueprint subclass of `AMyCharacter`, assign `DefaultMappingContext` and the three
`IA_` assets.
## Runtime rebinding note
The supported path for a "rebind controls" menu is Enhanced Input's **User Settings**, not
editing the `IMC_` asset:
1. Project Settings → Engine → Enhanced Input → User Settings → **Enable User Settings**.
2. On each remappable Input Action (or on individual mappings in the `IMC_`), set **Player
Mappable Key Settings** with a unique **Name**; that name is the save key.
3. Register the context with the settings object: `Subsystem->GetUserSettings()->
RegisterInputMappingContext(IMC)`, or pass `FModifyContextOptions` with
`bNotifyUserSettings = true` to `AddMappingContext`.
4. Remap with `UEnhancedInputUserSettings::MapPlayerKey` (an `FMapPlayerKeyArgs` naming the
mapping, slot and new key), reset with `UnMapPlayerKey` (capital M), and persist with
`SaveSettings`.
The settings object belongs to the `UEnhancedInputLocalPlayerSubsystem` (one per local player),
so it exists only while that local player does.
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| brainstormingobra/superpowersYou MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or planning anything new, in software or out of it (a talk, a business, a renovation). | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| brand-guidelinesanthropics/skillsApplies Anthropic's official brand colors and typography to any sort of artifact that may benefit from having Anthropic's look-and-feel. Use it when brand colors or style guidelines, visual formatting, or company design standards apply. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| frontend-designanthropics/skillsGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| mcp-builderanthropics/skillsGuide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when building MCP servers to integrate external APIs or services, whether in Python (FastMCP) or Node/TypeScript (MCP SDK). | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |