Download

UNREAL 4.21 - How to find out if an Axis Mapping button is pressed or released?

Hi, i´m implementing a Fuel system, each time my vehicle moves, it decreases fuel value…. the big problem i have, is that any InputAxis have a pressed and released option as Action Mapping Inputs have…. then, i canot find out if a button from “Inputaxis MoveRight” for example is been pressed and released.

I started solving this issue, by adding each of its buttons like A, D, Left, Right (wich do have pressed released), same for others, forward, etc, BUT… I canot do this for any GamePad Motion Controller, for example (L) Tuhmbstick X, because they only have integer values, and my fuel system becomes useless for gamepad.

What can i do, to figure out if an InputAxis (Axis Mapping) is been pressed or released?

You simply cannot do this. An Axis is a continous value.

If you want to check whether a direction is pressed, you need to check whether the InputAxisValue is != 0.

Keep in mind that AxisValues accumulate. I.e. if you have a single Axis bound to two buttons and press both buttons, you will receive an accumulated value of both pressed
For example A + D will result in 0 (-1.0 + 1.0 = 0)

Exactly, i understand, But… it is still a big problem in UE4 because it makes imposible to trigger any effect, or in my case use a fuel systems based on a vehicle movement, maybe there is other ways, please help.

Check float value of axis you want to check, is it > than, say, 0.3 (or, less than -0.3), if so - boolean this for some action you need.

What Thunder_Owl said is a good method.

But maybe you could even base the fuel drain on vehicle velocity, where the more the velocity, the more the fuel usage?

In this case, i do not use use velocity for every tipe of movement, just for some types of movements, like forward, but i do not use velocity for other movemens like side moves.

There is a get forwards velocity node

You could create an input action of the same key as your inputaxis and then you would have the pins for pressed and released. Could lead to trouble later if you allow players to remap keys. Or you just provide back end functionality that when a player wants to remap the forward button you just change it on both the input axis AND the inputAction. This seems maybe more efficient than checking the axis value continually.

You can use multigates to solve the problem. But you have to test performance.