How to fire exec only when Input Axis action happens?

I’m new to UE and do a simple test to learn how to move an actor by keyboard.
In the follow test, an axis action called “MoveUp” is declared in the input map for when “E” key is pressed.

351141-test3c.png

The blueprint for moving an actor is done as follows (there is also Input Enabled part but it is not shown):

I would expect that “InputAxis MoveUp” will fire execution only when “E” key is pressed, but its logic is different: It fires execution all time, and you need to use its Axis Value output for detecting if “E” is pressed.
This logic seems a waste of cpu usage because it executes the next component (Branch component in this case) all time.

Is there a way to make execution only when the key “E” is being pressed ?

Create an Action Input for E as well, use your logic with it instead of Axis Input.

As Shadow commented, you want to use Action mapping rather than Input mapping.

Axis is intended to simulate (to some degree) joystick input, which must send “at center” data when at rest.
Using the key alters which data is sent, rather than initiating it.

Actions work the way you are expecting.

If I understand the effort, this is what you’re trying to do.

Ok, got it, using InputAction instead of InputAxis. The given implementation need pressing “E” for each move step. Because I would like to have the actor moving while “E” is being pressed, there is need to add some more logic that convert one pressed exec, into a continues exec until “E” is released. I will try to find how.

No, not instead, but additionally. Use Axis for movement, and Action for what you need.

You can assign multiple inputs to one key, and they will all work.

Thanks Tuerer , that’s also possible and I will check this option too.
Meanwhile, I tried with InputAction instead within the shown graph.
When pressing “E” the while loop is executed which then should execute AddLocalOffset until the variable “Keep Move” became false. This will happens when “E” is released.

The problem is that when pressing “E” the game stopped with an error of “infinite loop detected”, but I don’t understand why - the while loop condition input gets the “Keep Move” boolean value which is set to false when “E” is released…

While loops are tricky in BPs. Try Event Tick + Gate instead maybe?

Edit:: Gate*

Is this what you’re trying to do?

Thanks Eslake - I tried your suggestion, but the Upward custom event doesn’t fire any ticks (I’m not familiar with Custom Event yet and how to make them fire triggers). Anyway, your graph show how to use the gate and with @Tuerer suggestion I got a solution.

I followed @Tuerer suggestion, and @Eslake graph made it clearer, the follow one does it:

Works! thanks :slight_smile: