How-to suggestion for Unreal 5.1

Hi!

I just figured I’d show one way to do this in Unreal Engine 5.1.

The easiest way is to use the Input mapping Context that we already have in Content/FirstPerson/Input, called IMC_Default for me.

What we want to do first is right-click in the content browser, and click Input Action.

image

This creates a new Input Action. I call mine IA_Grab. Open it, and set it to have value type Digital (bool). This is the field that was previously differentiated as Action Mapping or Axis Mapping.

Then we can open up the mapping context, press the + next to Mappings, and select our IA_Grab in the dropdown list.

Then we can set the keys for it, same way Sam does!

The input action then exists and works in Blueprints as well:
image

Started and Completed are like the Pressed and Released. Triggered is issued several times while the button is held down

If you wish, you can instead create your own Input Mapping Context and add all actions you want to that.
You do this by right-clicking and selecting Input Mapping Context. Open it up, press the + next to Mappings, and select our IA_Grab in the dropdown list. It has to be initialised somewhere however, so it’s easier to just add tihns to the existing one.

18 Likes

Thank you! You’re a lifesaver!

I’m on version 5.2. I got to the part where UE said mappings in the Project Settings were deprecated:

I then looked up how to do so in 5.2. This document is useful: Enhanced Input in Unreal Engine | Unreal Engine 5.2 Documentation

I added an Input Action as mentioned above. But then I also added an Input Mapping Context. It’s pretty useless for this project, but I did it to teach myself. Read on if you want to add your own IMC.

It’s been described that a “context” refers to what you’re currently doing. For example, whether you’re walking, or swimming, or driving. In different contexts, the same control might be used to produce different actions.

I believe you start in the context “IMC_Default.” But I decided to add my own context (again, useless for this project). To do so, right-click in your Content Drawer → Input → Input Mapping Context:

input mapping context3

I gave mine the boring name “IMC_Normal”.

Double-click IMC_Normal to open it up. Under Mappings, select IA_Grab, our custom Input Action. Then add the various inputs as usual: keyboard, mouse, etc.

However, the problem is, you start in the IMC_Default context. When the game starts, you need to switch to your new custom context. Following the picture at Enhanced Input in Unreal Engine | Unreal Engine 5.2 Documentation, we edit the BP_Player blueprint to produce the following:

Note that in the “Add Mapping Context” box, we select our custom context “IMC_Normal”.

When you start the game, this code changes BP_Player from IMC_Default to IMC_Normal, and then your controller inputs get properly mapped to the IA_Grab action, which then produces the outputs desired.

5 Likes

Thank you so much for this comment

As others have said, thanks for the clear and helpful post! Magical

1 Like

So I see how you create a new IA mapping, add it to your context ( which is set in the player controller ). I see in the Input Mapping Context the definitions. I can also accept that you need to setup IA_Grab in the controller graph.

What I do NOT see is how the existing mappings are working. For example W, as part of IA_Move. Where I see the “magic” is that where is the move action triggered? I see it will have an Axis2d type … but where exactly is this “executing” a move forward? I can’t find this at all anywhere.

That really depends on where you were to add the actual code/contexts for the action. As the project is based off the first person template, the default actions which have move, etc are in IMC_Default which is under /Game/FirstPerson/Input which can be found by searching the content drawer from the root folder.

Privacy & Terms