Download

Can you set the axis value of an axis mapping key?

Hi, UE4 users.

I’m having a problem where my one of my keys (and axis mapped one) gets stuck at an axis value of 1.0 even when entering a UMG widget, so my character keeps moving even after I close the widget.
The ideal solution would be to set the value the axis mapping returns to 0.0, but there is no way to actually set that value by force or force the key to be released so it resets.

Is there any solution to this problem?

Thanks in advance. :slight_smile:

Hi !

I’m not really sure of what is your problem but you could use an "action mapping " instead …

If you only want the state “1.0” and “0.0” and no value between those two then use an Action mapping … you’ll get the state “pressed” and “released” …

If my answer don’t help you or is not exactly what your looking for , please add more infos , maybe some screenshot showing the problem for us to be more usefull in our answers :wink:

Have a nice day !

Elvira.

I’m using an axis mapping for both keyboard and controller, that’s why I can’t go with an action mapping. Both WS & Left-stick up-down are assigned to MoveForward for example.

The problem here is that if for example W is pressed, obviously I get an axis value of 1.0, so my character moves forward. Then if I open a UMG widget while moving (I use Set Input UIOnly node to focus on the widget), the game stops focusing on my controls and keeps walking on while the menu is opened, which is not what I desire. The reason why this happens is because MoveForward is outputing 1.0 because the key is pressed, but after the menu is opened it no longer detects if the key is changing its state, so even after releasing the key or exiting the menu, it will still output 1.0 which is problematic.

What I’m aiming for is just to have the character move and if the menu is brought up, stop the character’s movement and keep it like that until you’ve exited the menu.

Oh okay i see ,

Well my idea is to use a gate …

Something like : eventTick -> if condition to check "is in UI " (or something like that ) : if false then close the gate , if true then open the gate ,

beside that you have your axis mapping plug into the gate then the gate plug into whatever you want (character movement in this case ) , and this state will only trigger when your not in the UI :wink:

I’ll add a pics of the whole concept in a few minutes :wink:

here it is :slight_smile:

Thanks for the pretty example but I think you’re not understanding what’s the real problem. Even if I did what you just posted, the problem would still be the same.
The deal here is that the moment you enter in UI mode Only, the axis mapping doesn’t go back to 0.0 unless it detects the key has been released, which it can’t because it’s in UI mode (no longer detecting key presses handled by the player itself [Game Mode]). When the input enters the gate, it will still receive a 1.0 output because the axis mapping hasn’t been reset to 0 again.

EDIT:

If you want to see what I’m talking about, create a new template project, 3rd person template.
It should come with basic controls like this:

&stc=1

Now, implement this. Just opening a widget and setting the UI widget as the focus.

&stc=1

The widget just needs to be a text to show that it’s running. Now try to run and while running press K and you’ll see the problem.
If after that you still think that the gate system solves it. Implement a button for exiting the menu and you’ll see what the real problem is.

oh okay i see , well just after your “k” key input you just need to set a variable (bool ) to true ; something like “isInUI”

then after your axisInput and before the addMovementInput simply add a if condition :slight_smile:

something like InputAxis -> if isInUI = true -> just leave with nothing , else if isInUI = false then wire the false pin to addMovementInput :slight_smile:

This should Work just fine :slight_smile:

That’s what I was doing to begin with. Try with that setup you just posted to do this: Move -> Open menu -> While menu is opened release the key you pressed to move (W for example) -> Close the menu
That way you’ll see what’s the problem behind it. You can stop it from moving before the menu opens, but after you close it and return the control to the player, the player will start moving because the axis is set to 1.0.