Character Movement Enhanced Input System in Unreal Engine 5.3

By | March 29, 2024

The days of using the old input system in Unreal Engine are behind us. The new Enhanced Input system might seem daunting at first, but once you get started, it will make sense, and you can add all sorts of input in seconds!

In this article, we will make a basic character movement system using the Enhanced Input System.

What is an Enhanced Input System?

If you have no idea what it is, fret not. Here is the basics. The Enhanced Input System lets you set up very complex key binds with little work. You will still add keys to action like you used to before, but now they have more built-in functionality.

You Only Need Two Things

To get started, you need two things, Right Click on your content browser to get this menu, Then go to input as it’s shown in the image. You should see these two options there.

  • Input Mapping Context
  • Input Action

Input Mapping Context

This is used to combine all your input into a single place. Like a Map, it’s right there in the name! This allows you to combine different functionality. We will show you how to use this effectively later in the article.

Input Action

Input action looks like what we used to do to set up the input component. There are some changes, and it has some new features. Worry not; this part will feel quite familiar.

Setting Up The Mapping Context

You can start by naming it IMC_[*ThirdPersonMappingContext] or *something that makes more sense.

Going inside, you should see something like this! Good job, setup is done!

Adding Inputs With Input Action

This time, click on Action input to create a new action input, and you can name it AI_[*movement] or *something that makes more sense.

Getting inside, you should see something like this

To set it up for a character movement, you need to change the value type from bool to Axis2D(Vector2D)

Our Job here is done! Now we need to add the keys in the input mapping context.

Binding Keys To The Action

Click on this (+) icon to add new mappings.

This is the complex part that we need to set up, and we can have our character moving Right, Left, Forward & backward.

W/ Forward

Click on the drop-down and select the input action AI_[Your name] file you just created. then click on the (+) sign to add as many keys as you want. We will add W as our first input.

Add a modifier by clicking on the (+) icon on the modifier line and set it to “Swizzle Input Axis Values”. Also, make sure the order is like the image “YXZ”

Keep doing this 3 more times, but each time, we change the settings a little bit to incorporate the intended movement.

A/Left

We are going to add input A and add a modifier by clicking on the (+) icon on the modifier line. To go left, set the modifier to Negate. Because, by default, the action will move the character to the right. Everything else should look the same by default, but you should check to make sure, just in case.

S/Backwards

We are going to add input S and add a modifier by clicking on the (+) icon on the modifier line and set it to “Swizzle Input Axis Values”. Also, make sure the order is like the image “YXZ”

Now add another modifier by clicking on the (+) icon on the modifier line and set the modifier to Negate. because it’s the opposite of moving forward.

D/Right

Moving right is the easiest to set up because, by default, the input moves the character to the right, so all we need to do is assign it to D, and we are done with the input.

Adding Movement to Character Blueprint

First, we need to add the mapping context to the blueprint with this segment of scripting then we can use the keys we set up so nicely. So add this inside of your character blueprint and you are just one stop away from moving the character

Then search for the input with the input action name you set before and add this.

Let’s split this into two parts to explain better which is doing what

This part above will move the character to the Left and right.

This part above will move the character Forward and backward.

We are done, but why not add a mouse input to move the camera?

Mouse To Move The Camera

Create an input action and set the value type to Axis2D(Vector2d)

This time all you need to do is set the input to mouse XY 2D-Axis.

Add this to your character blueprint, and it’s done. (Assuming you already have a spring arm and camera setup, and it inherits transform from character)

There you have it. It wasn’t so hard, right?

Leave a Reply

Your email address will not be published. Required fields are marked *