Basic problem when trying to detect if a key is held for five seconds

This is probably a very basic solution I’m looking for here. I’ve just started using Unreal Engine two days ago and I’ve been trying to learn Blueprints during that time, but I’ve run into a problem that I can’t find any help with.

Here’s the blueprint so far.

Probably not the most efficient. The basic rundown is that I have an object. If I stand in front of this object and hold E for five seconds, something should happen to the object; in this case the object is destroyed. While holding E, the object is being “overridden”. So from the bottom left upwards: Event tick will check if the player is overriding. The conditions to override this object is to just be holding E, so when the player releases E, isOverriding is set to false. While the player is overriding, the blueprint will take the time he’s been holding down E for, then set the “Hold Time” variable to equal that.

After that, I’m checking if “Hold Time” is greater than or equal to 5.0. This is where the problem arises, and it’s stumped me for almost two hours now. How do I lead on from the the greater than or equal to operator, directly to the destroy actor graph? I’ve run a few debug checks and found that at the time of releasing E, hold time is definitely above 5, and it’s hooked up to the greater than operator, so it should definitely be comparing. I’ve even forced the “is greater than 5” boolean to true, and it executed the Destroy Actor function properly.

The only problem is how the hell do I actually wire anything to the “exec” pin in the set block that’s setting “is Greater Than 5” to true? My logic is that after checking if Hold time is greater than 5, the set block should execute right after, but it doesn’t seem to do so because the set block isn’t powered, so to speak. I’ve hooked it up to the “is Overriding” set block to check if that’d work, and the Destroy actor function is executing like it should, but just at the wrong time.

How do I execute this “set block” right after I compare “hold time” and check if it’s greater than 5? I’m probably thinking of this the complete wrong way around, and I can’t find anything on the internet that will be of any help because I can barely explain what’s going wrong myself.

Hello,

Try this setup instead:

What I did was basically create a trigger volume in my level and then I set this up in the level blueprint for testing purposes. You’ll always want to cast to your character class, just to ensure that it is actually your character overlapping the trigger, and not some other actor in your level.

It’s pretty similar to your setup, with a few minor changes. Let me know if you need further explanation.

Have a great day

Man, that’s exactly what I was looking for! It works as intended now, thanks.

Glad you were able to get it working!