Holding input action instead of specific key for event trigger?

Has anyone tried this method to make an input action trigger after a set amount of time? I’m trying to get my character to go prone when the Crouch button is held down after a short amount of time, instead of tapping it. I’m trying to save on button mappings for game pads while also keeping the ability to remap down the line by not using the “is key held” function, as some users have stated that this can prevent/break remapping at a later date.

I have C and Gamepad Face Top button mapped to make character crouch, and I would like the player to be able to enter prone by holding those same buttons instead of tapping them, which would still be to enter crouch. Does anyone know of a proper config for this to work?

Thanks ahead of time,

George

I can also post some photos of my current blueprint when I get home, if that helps, however I am at work right now and don’t have access to my project.

I had a similar issue before and i resolved it from level blueprint. You can adapt it in your project.

Steps:

  • Create a variable “KeyIsPressed” as boolean
  • Create a key node (Let’s say “C” key for pressed and release
  • set KeyIsPressed to true for pressed or false for release.

Have a look on the attachment image.

In my case it’s work. let me know if it works for you.

Here is a screenshot I have of my current blueprint. I already have crouch functioning fine when C is pressed. It goes in and out of crouch by just tapping C.

What I’m trying to do is have the player hold C, so that the character then goes into prone, like any shooter game nowadays. I don’t want to remap prone to another button, because it seems like a waste of space to me, which is probably why a lot of games use the “hold” function.

There is a “input key held” function, but it specifically makes you choose what key to hold. Instead, I’m trying to find a function that takes the input action of crouch and when the player holds whatever button is used to crouch, no matter the mapping, the character goes into prone.

The delegate function I have in there is wrong, as it sets a timer so far to initiate prone, but it has nothing to do with the button being held down. It just initiates prone after the set time, no matter how long the button is pressed.

OK i just got your comment. I wrote you from home and I don’t have Unreal in my home PC. However, I play with the Paint to show you how i would do it from your images. Have a look on my 2 images.

Image1:

Image 2:

I understood that your delegate function is wrong, but try to get my idea!
Let me know if you still not get it!

Ah, ok, I think I’m getting it. Do I still need to use the delegate function so I can adjust the length of time to hold the button to initiate crouch, or is that the wrong node? Your setup makes a lot of sense though. Thanks again for helping!

I’m having a problem setting it up as I still don’t know how to set the time aspect. I’d like to have the player hold the crouch button for about a third to half of a second to signal the prone state, but I’m having trouble finding the proper node for that.

This is where I’m sitting at now. I feel like I’m getting closer, but still not functioning as intended…

Hey! Sorry for the long delay! I had a rush at work today and Yesterday. Tomorrow i will more focus to your question. However, i suggest you to try to improvise the nodes the Get Player Controller node and the Get Input Key Time Down node.

38097-thenodes.jpg

Watch this link:

Try this (view attachment picture)

Let me know if it’s not working than i will try with your example.

I answered the question: view the answer below.
:wink:

Easiest way to do all this is with a timer event or function you don’t even need to use event tick . When you press the button simply have the timer add 1 to a variable eg fingerHold duration . Then check if fingerHoldDuration > desired held time if true continue with logic. Then from released simply clear timer , reset the variable back to 0 . One thing you need a do once before the event timer otherwise the loop of the event will fail to execute as it will keep trying to call the event but never actually execute the logic . This had me stuck for ages .

Best answer so far. Using tick for such thing is a bad habbit. :stuck_out_tongue:

I’m guilty of overthinking this one too. Same concept as going prone, I just want to hold an input to use a bandage to stop bleeding. I’ve got a five second long timeline that will only finish if the desired button isn’t released. Hold time you can ignore, as well as the update execution (unless you want to drive HUD changes there).

1 Like