Unreal Engine: Enhanced Input Actions (Keyboard + Controller)

If you’re using Unreal Engine 5.1 or a newer version, it’s a good idea to use the Enhanced Input System to set up the keys and buttons for your game. It doesn’t matter if you are using a controller, a keyboard, or both.

In this blog post, I’ll show you step-by-step how to set up the controls for your game.

This way, you can make your character move, jump, open doors, or do anything else you want them to do.

I will explain briefly how to set up inputs in earlier versions of Unreal Engine. Feel free to jump to the first step if you are using Unreal Engine 5.1 or a higher version.

Enhanced Input for Unreal Engine 4

Don’t worry if you are using an older version of Unreal Engine, such as UE5.0 or UE4.

Simply activate the ‘Enhanced Input‘ plugin and follow the tutorial.

Also, make sure that in the Project Settings, under Engine -> Input, the Default Player Input Class is set to ‘EnhancedPlayerInput‘. The same goes for the Default Input Component Class, it should be set to ‘EnhancedInputComponent‘. Here you can find more information.

Default Player Input Class

Alternatively, you can use the old method to set up the inputs for your game.

To do this, go to Project Settings -> Engine -> Input, and edit the Action Mappings and Axis Mappings.

If you are a beginner and need an example, just open the third-person template in Unreal Engine 4 and take a look or read the documentation. However, it’s important to note that this is the old way of configuring inputs, and it is deprecated in newer versions.

1. Create the Input Actions

The first thing to do is create an Input Action.

In this lesson, we’ll create two actions: one for an easy button action like jumping, and another for moving the character, which might be a bit trickier. But I’ll do my best to explain it clearly.

So, in the Content Drawer, right-click or press the ‘+Add’ button, and select ‘Input’ -> ‘Input Action’.

Let’s create two of them: one will be called ‘IA_Jump’, and the other ‘IA_Move’.

Obviously, you can create as many actions as you want for your game, such as actions for crouching, opening doors, attacking, or whatever you need.

Create Input Action Unreal Engine 5

2. Setup the Input Actions

Once we have the Input Action assets, let’s open the first one we created for jumping.

Jump Input Action

Here, just make sure that the Value Type is set to ‘Digital (bool)‘, as it will only output two values: True or false.

It indicates whether the player is pressing the button or not. Essentially, a yes or no scenario.

I also recommend adding two triggers: one for when the button is ‘Pressed‘ and another for when it’s ‘Released‘.

Move Input Action

On the other hand, for the movement action, we need to change the Value Type to ‘Axis2D (Vector2D)‘.

This is because we need to know the float values for left, right, up, and down to understand where the character is moving.

You don’t need to add any triggers here. Don’t forget to save, and with this, you’ve completed the second step

Enhanced Input Action Set Up Unreal Engine

Tip: If you don’t know what a Bool, Float, or Vector is, please read our lesson on Data Types and Variables first.

3. Create the Input Mapping Context

Now that you have the two actions ready, remember they don’t work on their own.

We haven’t told the engine which buttons make the character jump or move, so since the input actions are not connected to anything, they won’t do anything.

To connect everything, we need to create an Input Mapping Context.

So, in the Content Drawer, right-click or press the ‘+Add’ button, and select ‘Input’ -> ‘Input Mapping Context’.

You can give it any name you like, I’ll call mine ‘IMC_Player’.

4. Setup the Context Mapping

Now, open the Input Mapping Context you just created, and we will start setting up everything together.

First of all, press twice the ‘+’ symbol next to ‘Mappings‘ and select the two Input Actions you created in step 1.

Next, select the input you want to use to jump. In my case, I will choose the Space Bar.

However, if you press the ‘+’ symbol next to ‘IA_Jump,’ you can add as many inputs as you want, including controllers and touch pads. All the buttons you configure here will execute the same action.

Tip: To add the input you want more quickly, just click the keyboard icon. The icon will change to yellow, and then you can press the key on your keyboard that you want to set up.

Then for ‘IA_Move‘, let’s repeat and create inputs for 4 keys: W, A, S, D.

I also recommend adding the Gamepad Left Thumbstick in case you want your game to be playable with a controller.

Input Mapping Context UE5

With this, you are almost finished. You just need to add modifiers to the Move Action.

Input Modifiers in Unreal Engine

This is the tricky part, as we need to configure modifiers for player movement.

First, we need to differentiate between up and down input and left and right input. To do this, add the ‘Swizzle Input Axis Values‘ modifier to the W and S inputs.

Next, we have to set up the negative values. In this case, moving to the left (A) and down (S) should have negative values. Up and left (D) and up (W) should have positive values.

To achieve this, you need to add the ‘Negate‘ modifier.

  • W: Swizzle Input Axis Values
  • S: Swizzle Input Axis Values + Negate
  • A: Negate
  • D: Without Modifier

For the gamepad, you need to add the ‘Dead Zone‘ and ‘Scalar‘ modifiers.

Here is a complete list of all input modifiers if you are interested in what they all do.

Enhanced Input Modifiers List

  • Dead Zone: Input values within the range LowerThreshold -> UpperThreshold will be remapped from 0 -> 1. Values outside this range will be clamped.
  • FOV Scaling: Apply FOV dependent scaling to input values, per axis.
  • Negate: Inverts input per axis.
  • Response Curve – Exponential: Apply a simple exponential response curve to input values, per axis.
  • Response Curve – User Defined: Apply a custom response curve to input values, per axis.
  • Scalar: Scales input by a set factor per axis.
  • Scale by Delta Time: Multiplies the input value by Delta Time this frame.
  • Smooth: Smooths inputs out over multiple frames.
  • Swizzle Input Axis Values: Useful to map a 1D input onto the Y axis of a 2D action.
  • To World Space: Input space to World space conversion. Auto-converts axes within the Input Action Value into world space allowing the result to be directly plugged into functions that take world space values.

5. Call the Enhanced Input System in Blueprint

Lastly, you just need to activate the ‘Enhanced Input Local Player Subsystem’ inside your player or whatever blueprint you want to use.

It’s a way of telling Unreal Engine that this blueprint is going to have access to the Input Mapping Context we just created.

Tip: If you don’t have a character yet, take a look at our Game Mode lesson or check one of the Unreal Engine default templates, such as the third-person template.

To get this working, you will always need the following Blueprint code:

  1. Event BeginPlay
  2. Cast To PlayerController: Connect ‘Get Controller‘ to the ‘Object’ input node. From ‘As Player Controller’ connect the ‘Enhanced Input Local Player Subsystem‘.
  3. Is Valid: Connect the Enhanced Input to the ‘Input Object’ node.
  4. Add Mapping Context: Connect the Enhanced Input to the ‘Target’ input node. Don’t forget to select the Mapping Context you created in Step 3.
Enhanced Input Local Player Subsystem Blueprints

6. Add the Input Events to your Player Blueprint

Congratulations if you’ve come this far! Now, to finish, let’s put it to the test.

To finish, create an event for the two input actions you created in step 1.

The events will have exactly the same names as the input actions. They just start with ‘Enhanced Input Action’. It should be easy to find the event nodes.

Now let’s connect a Print String to the two Enhanced Input Action Events to check what happens when we press the WASD and Space Bar keys.

Tip: You can right-click on the ‘Action Value‘ output node from the ‘IA_Move’ action and select ‘Split Struct Pin‘ to get the Action Value X and Y separately.

If you did everything correctly, when you press play, you will see a text message in the corner of the screen with the messages we just set up using the Print Strings.

Enhanced Input Action Event in Unreal Engine

I hope it helps! Keep creating!

To learn more read the Unreal Engine Documentation.

Unreal Engine Roadmap