How to Reset Key input lockout with another Key? Please help!

A bit new to Unreal engine, I want the A Key and D Key input from the Keyboard to move the player to face a specific direction, with the W key resetting them to face forwards, it works fine so far. However, whenever pressing another key after one it starts the pawn rotation from default position. Causing a jarring Teleport between the two positions. I have managed to prevent the camera teleporting between positions by locking the key input through a Branch. However, this lock appears to be permanent after one use.

How can i reset this section for once the W key is pressed to allow the player to transition between A position and D position?


Here’s what the code looks like so far, I understand if it’s very bad ^^’

Hello and welcome,

Couple of issues with code apparent, you don’t appear to be resetting A Pressed or B Pressed anywhere, so once triggered once they will indeed be locked on.

You are also using outputs from nodes in one event handler as inputs for a node in a different event handler, there are nodes you can share like this (ā€œpureā€ functions and casts) which you probably don’t know about yet, a set node is not one such and if you are new to this I would just advise to avoid doing it altogether.

Fix those two issues like so, but with D substituted for B where appropriate :wink:

Timelines seem a bit messy here, I think you will have less problems (and a better result) using an RInterpTo or RInterpToConstant node with current rotation and a target rotation.

Whichever way you go, good luck!

1 Like

Thanks for the advice! What you showed does help with locking the Keys out, from being pressed while the other is. I didn’t release that, that is how you setup Set nodes.

However, I’d like to keep them locked until the player presses W, because while the locking you suggested prevents the jarring teleport during a press, it still jumps afterwards. I’m not too sure how to fix that issue.

And thank you for the suggestion on using RInterpTo and RInterpToConstant nodes instead.

The easy suggestion is of course do just set them both false on the W key handler… but I see you have two (which I did not notice before), and they both feed into timelines that update rotation. So you have another problem, when you press W both timelines will be playing (reverse) at the same time, one clobbering the results of the other.

With your current setup you would need to (somehow) remember which button was pressed (Was Button A/B Pressed, perhaps), set both existing flags to false, then branch on which button was selected before and take the true/false exec pins to the appropriate timeline.

It is about this time that I must recommend again you have a play with the RInterp functions and then re-implement this, going to make your life much easier!

1 Like

Using FInterp To (because you are only modifying yaw anyway):

1 Like

Thanks so much for the advice and suggestions, I’ll play around with
RInterp functions some more, what I’ve been using has mostly been based off of what a tutorial had shown but had a few issues with what i was actually looking for so I had to try and edit it.

I’ll try out what you gave, thanks so much. ^^

Managed to get the system working with your suggestion, and it forces the player to have to press W to switch to the other camera positions.

It may seem a bit janky, but if there are improvements feel free to advise them.

1 Like

I was under the impression from you original post that the input disabling stuff you added was not really desirable, but needed to solve the rotation reset problem?

This was part of the reason I suggested using Interp functions instead of timelines, to make this easy to do without having to worry about the rotation reset (which admittedly could also be solved while still using timelines, just far less conveniently).

Your solution is still tracking button presses and disabling actions with those flags… is that something you actually want? Because you don’t need it now, you are always ā€˜starting’ from the current rotation (even when a rotation is in progress), so that original rotation reset problem does not exist anymore.

1 Like

Sorry for the confusion, The disabling was desirable, the issue was the rotation reset, which was a little buggy in playtesting. ^^

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.