skip to Main Content

Implementing Action Bindings with parameters

In this post we’re going to create various Action Bindings with parameters. Moreover, we’re going to see a way to change the content of our parameters on run time!

This post assumes you’re familiar with UE4 Delegates. In case you don’t quite remember, or know, what or how to use them, I’ve got you covered!

Creating our Inputs

Create any C++ project template and add the following action mappings:


Then, open up the header file of your character and add the following functions:

Then, inside your character’s source file add the following implementation for the OneParamFunction and the TwoParamsFunction:

Before we go any further let’s take a step back to explain how inputs work in C++ inside UE4.

Your character contains a component named, InputComponent (at least this is happening on the template project !) which is responsible for checking if a valid device for inputs (such as a gamepad / keyboard / mouse etc..) exists. Moreover, that component contains all the available inputs for the specific character.

Currently, there are two types of bindings in UE:

  • Axis bindings
  • Action bindings

The main difference is that axis bindings execute in each frame, whereas action bindings execute when certain conditions are met (for example the user double clicks, or presses a button).

In this post we’re going to focus solely on action bindings.

In order to declare an action binding you need to:

  • Associate the action mapping we’ve specified using the Editor with an input event (ie a button press)
  • Declare which function will fire when the input event occurs

Inside the First Person C++ Project template you can locate the following line of code inside the SetupPlayerInputComponent:

This is the standard way to add an action binding. In this post, we will explore a different way of adding an action binding.

In reality, inside C++ an Action Binding is actually a struct which contains useful information, such as:

  • Action Delegate (I will explain in a bit what this is)
  • Action Name (which is the actual name of your binding – this must be associated with the action mapping that was specified in your Editor)
  • A Key event (which describes the input type. In our case we’re going to use the IE_Pressed key event which describes a button tap)

The Action Delegate is essentially a handler, which points to a function that will execute when we have a valid input based on the key event of our Action Bind. Having said all that, locate the SetupPlayerInputComponent function and add the following code after the default inputs:

The remaining steps are to implement the function ChangeParameters and specify some initial values for our exposed properties through the Editor.

Changing our variables on run time

The ChangeParameters function will generate two random values and will re-bind the TwoParamsInput Action Binding. Having said that, here is the implementation:

Save and compile your code. Then, switch to your Editor and:

  • Assign values to our variables from within the character Blueprint
  • Test your code

Here is a screenshot of my default values:


And here is a screenshot of my end result (after calling the change parameters function a couple of times):




Avatar photo

This Post Has 3 Comments

  1. Hello, great tutorial but I found an issue(this might have changed since you posted this). When I bind the uFunction’s with the action handler’s, the third parameter does not show up and it will give me errors that this will not work. I’m using Engine version: 4.15.1

    1. Hello,

      It would help a lot if you post your code in a pastebin link so I can see what’s going on.


      1. Sorry about the late reply, wasn’t able to get to my computer. But I found out what the issue was, instead of delcaring FInputActionHandlerSignature, I declared FInputActionHandlerDynamicSignature by accident and that was why I was having this issue. Apologies for bothering you with my question, but atleast if anybody else has the same issue now they can see to check that as autocomplete might have used FInputActionHandlerDynamicSignature instead of FInputActionHandlerSignature. Fantastic tutorial though! 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Back To Top