Input Held Down?

a8511b97ff72988ff46c1f6d98c5efeff9fd2f76.jpeg

A gate might also work for having a button being “held down” Could hook it up to Event tick or the timer as shown, depending on the use.

I’m just trying this out but I can’t get it to work yet.
My original Blueprint looks like this.
When I release space it fires an impulse that is represented by “float Jump Power”.

I would like the “float Jump Power” to be controlled by a timeline, say a value of 0 to 2000 over a timescale of 2 seconds.
When I release space I want the float to be triggered so that if I hold key a short time I get a little impluse and if I hold it for a long time I get the maximum value (2000).

Currently I have this but its firing all the time so I need some way to trigger it when space is pressed but not update the float until its released.

I hope this makes sense ?

Fixed it with thanks to James on https://www.facebook.com/groups/unrealfour/

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. Does anyone know of a proper config for this to work?

If you deselect the ‘Context Sensitive’ checkbox when you are searching for new nodes then you will find the Get Input Action Time Down. I had to do that.

Here is another solution that will set a ‘power’ variable determined by seconds held.

This doesn’t involve timers or ticks.

Under the Normalize to Range node “Range Max” is the time in seconds you want the button to be held in order to achieve max power.

The float multiplier node just after holds the value of what your max power should not exceed.

In my example if the button is held 4 seconds or longer the result 2000 is produced. If held down for 2 seconds 1000 would be produced.

So on…

SET X_DIFFERENCE is not actually needed and can be removed from the blueprint.

Not tested but should work.

The downside to this method is that you cannot update anything in real-time in relation to X_Pressed since there are no timers checking the values. You must wait until X is released before this will fire off. It has limited uses but is fairly efficient and problem free.

“The downside to this method is that you cannot update anything in real-time”

yes you can: on tick, subtract X_Start from GetGameTimeInSeconds.

you really don’t need the “X_End” variable at all, you only need to keep track of the starting time, and you can subtract it from the current time whenever you need to get elapsed time. elapsed time is updated so frequently that its a waste to store it in a variable, and more efficient to do the subtraction every time you need it.

Thank you so much for this! I really needed it. :smiley:

Unfortunately, I cannot make this work as I would want to. X Power should never be more than 2000 in your example, right? I don’t know why, but I am using this exact blueprint and my X Power is always bigger than the number inside the multiply node? I am a noob still, so I’m sorry if I said something wrong. :slight_smile: Cheers

Hi Steve,

Is there an equivalent for this for touch screens?
Sometimes my game interprets the starts of swipes as a touch and fires off the touch action by accident.
I’d really like to implement a minimum time for how long I’d like a touch event to last.

Thanks!

why there are no hold down button event ?? is it hard to make one ? pls epic team make an event for hold down button .

i spent all day to find a good method and found this which it worked for me and my IQ i think raised by +1 after losing during research :slight_smile:

here it is ,a R delay hope it will work for you guys :

dac1d87fe7d67e32a6dc48e540966e4e8fec1986.jpeg

ignore the branch of hold jump its part of my project , and the event you want to be trigger put it instead of "start floating event " .

Here’s a good way to get the Widget Interaction Component and your 3D Widget working with a MOUSE CLICK.

Go into your Characters blueprint.

  1. +Add a “Widget Interaction” component from the component window.
  2. +Add a “Widget” component from the component window.
  3. Make sure the Widget Component has your Widget of choice in the ‘widget class’.

These are my settings for the Widget interaction component:

Go into the graph editor of the blueprint widget you selected before.
Find your desired button, (or whatever you are using. I’ve only tested this for buttons), you want to work with the Widget Interaction component.
Click the “>OnHovered” Event for that button.

Then do this for that OnHovered event:

It is worth noting I have another identical button that gets created on top as soon as the button (involved in this tutorial) is clicked. That means if I added this system to that new button it will jump into a fast loop requiring the need for a doOnce node.

Thanks! It what to need)

Not to bring a dead thread back to life, but I implemented my own system using only the game time, a bool and simple arithmetic if anybody is interested. You just get the game time when the key is pressed, record it, then get the game time when the key is released and record it. Subtract the value from when the key was released by when the key was pressed, and if the difference in time is larger than a predefined value, then it will trigger the held boolean value and switch the branch to the Held function.

Since the question about other ways, (input actions), being used was never really answered I came up with this method. When the input action is pressed you store whatever button that was into a variable then plug that into the Get Input Key Time Down so it doesn’t matter what button your player is using for say Trigger. I put the delay there because it’s in tick but you can remove this for exact timing or extend for things you don’t need immediate response from. The branches allow for not wasting resources on the math if you’re executing the other code and releasing the button flips that boolean so you can repeat the process later.

Very old thread. But my solution was to see if input was still held after a timer went through for like .13 seconds. If the key was released, then when I went to check if it was still held after the timer is up, it would perform the input-pressed action. Otherwise it does the input-held action.

seems to be the most straightforward to me

Maybe this is even nicer

The Time does not work with 0 though, but can be set very low, if one wants to emulate a high frequency ticking

Lots of useful information in this thread. Thanks guys!

While reading it I was wondering why isnt there a node called "action/input down’ in addition to the ‘Is Input key down’ one. That would be super useful because I have setup a lot of alternative keys to all of my actions. “Crouch” for example being both S from the WASD block and the down key from the cursor key block and some gamepad keys.

But than I noticed that you can feed the keys from the InputAction node into the key down node instead of directly picking a singular key! So as long as any of the possible inputs are down the bool is set. In my game rebinding of keys is not yet possible but I would assume this setup would also automatically handle those keys .

KeyDownForInputActions|690x208

Just postingthis for people from the future who find this thread!

I was struggling for while with this issue too, I eventually made this and it shouldn’t be expensive to run unlike some of the other solutions here

3 Likes