Disable specific keyboard key in level blueprint

My issue is incredibly simple, however I’ve been searching the net for an hour or two on the issue.
What I want to do is disable and enable a set of specific buttons when I hit a trigger box. The triggerbox itself is already set up and ready to be used, however I can’t find a way to disable a specific keyboard button. Thanks!

Move the UpDown variable to whichever class you have the input in. Then, in your level bp, set that variable on that object. You can use get player controller 0 or get player character 0, etc. to get the object you need. Then check the state of UpDown on your input events.

There is disable and enable inputs, maybe they can be of use? I used them recently to disable E key when opening / closing a door. Just right click and search for disable or enable they should come up. :slight_smile:

If I move the variables to another blueprint other than the level blueprint I can’t communicate between them, which is half the issue I’m facing. I would have done so already if I could.

I got a blueprint which checks if my character is in my triggerbox or not. Each time my character enters the triggerbox, it activates the checkUpDown_blueprint event, which in toggle the UpDown variable from enabled to disabled.

When my character leaves the triggerbox the checkUpDown_blueprint will fire again and toggle my UpDown variable to enable again.

The image below pretty much explains what I’m trying to do.

Care to show a example? That sounds just exactly what I’m after, as you can see on the picture I showed above, that’s what I’m working with currently, and all I need to do is disable the W & S keys. If I use player controller 0 or anything like that it’ll just make me lose control of the character.

It’s quite hard to communicate character → level. However, level to character communication is easy. Use the Get Player Controller node - and use index 0. This is always the local player’s player controller. Cast this to your custom player controller (if your input code is in there) or do get the pawn from the controller and cast that to your custom pawn if it’s in your pawn/character. Then set the variable on whichever you used. Make sure the variable is “editable” (has a green eye symbol next to it.) While these aren’t best practices, it will make what you’re doing very easy.

Looking at the other method for a moment, it has the big side effect of you not being able to move out of your trigger box (if you do that via movement keys.)

If I use player controller 0 or anything like that it’ll just make me lose control of the character.

No it won’t.

I don’t really need to get the character, or the player controlls, as the key isn’t bound by the original controller. even if I lose control over my character, my W & S keys will still work, that’s why it would be nice to be able to isolate and disable just a specific key, and should (probably) be able to be done in any blueprint (I think)

Recap:
I wanted to use a triggerbox blueprint to make sure you couldn’t use a set of controls (in this case W and S). My first instinct would be to disable the button while going into the triggerbox, which is basically what I’ll be doing in the end.

How I did it:
In the triggerbox blueprint I used the normal actor overlap and immediately casted to the player (N_playerCharacter)
and then fire a custom event I created in the N_playerCharacter blueprint though the casting.


Next up was to make the custom event which will be fired though the casting to disable the keys. This was fairly simple, I made a standard toggle with a boolean variable and printed some debug string to make sure it worked.


last but not least is the finale, I simply had to check the boolean every time is active or not, and in my case, while false the W/S keys with simply just output a string saying that nothing will happen. On true I of course simply continued as it did with the script before.


and here’s the entire flow!