Course contentsShow
← Unreal Engine Game Development
Lesson 226 of 8804. Advanced Input and PhysicsFree lesson

Defining Abstract Input Actions

You will create reusable Input Action assets to represent functional game intents like jumping or firing, independent of specific hardware buttons.

In this lesson, you will learn how to decouple your game logic from specific hardware inputs by creating abstract UInputAction assets.

The Problem with Hard-Coding

In early development, you might be tempted to bind logic directly to keys like E or Spacebar. However, this creates a "hardware dependency." If you later decide to support controllers, rebindable keys, or different platforms, your code breaks. If you hard-code "Spacebar," your character won't jump when the player presses the "A" button on a gamepad.

The Abstract Approach

Unreal Engine’s Enhanced Input system solves this by introducing a layer of abstraction. Instead of checking for a button press, your code waits for a Functional Intent.

An Input Action (IA) is a data asset that represents what the player is doing, not which button they pressed. You create an asset (e.g., IA_Jump), and your C++ logic binds to that asset. The actual mapping—deciding that "Spacebar on Keyboard" or "Gamepad South Button" both trigger IA_Jump—happens in a separate file called an Input Mapping Context (IMC).

Implementation

When you define your character class, you don’t look for keys. Instead, you declare the Input Action as a UPROPERTY in your header:

UPROPERTY(EditAnywhere, Category = "Input")
UInputAction* JumpAction;

In your SetupPlayerInputComponent function, you bind your function to this abstract asset rather than a hardware key:

EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Started, this, &AMyCharacter::Jump);

By doing this, your Jump function remains completely ignorant of the hardware. It only knows that the "Jump Intent" was broadcast. This architecture allows you to change your control scheme entirely within the editor's data assets without ever touching your compiled C++ code. Your logic stays clean, flexible, and perfectly decoupled from the user's specific controller.

Key Takeaway: By defining Abstract Input Actions as data assets, you decouple your game logic from specific hardware, allowing you to easily rebind controls and support multiple input devices without modifying your codebase.