Function after time

Im very new at Unreal Engine and ive got a small, probably very easy question.

I want to play a sound after 1 button-combination (like left shift + L) is pressed for at least 5 seconds.

So i press Left Shift + L for 5 Seconds and the sound begins to play.

Anyone can help me with this ? :slight_smile:


Ok, on the key-pressed node, near the beginning of your chain of commands, put a Set Timer and 5 seconds, have it run the function of MakeSoundPlay. On the key-released execution line, put a Clear Timer of the function MakeSoundPlay. In the function of MakeSoundPlay, play your sound.

Ive only got the Set Timer by Function Name and Event, Clear timer by event and no MakeSoundPlay ?! :open_mouth:

MakeSoundPlay is a function you create. Easiest way is to select your “Play Sound” Node (or place a Node “Play Sound 2D” for example), right-click, “Collapse to function” and name it “MakeSoundPlay” (name doesn’t matter, if you put the same one in every place).
Then hook up “Set Timer by Function Name” to Pressed, fill out the Function name (as “MakeSoundPlay”); and do the same for “Clear Timer by Handle” with Released. Plug the Handle output from “Set Timer” into the input of “Clear Timer”.

Sample here:

Hallo BhaaL!
Hab das eben genau so gemacht wie bei dir… nur wenn ich nun Set Timer mit Make Sound Play verbinde… hört es nicht auf zu spielen… wenn ich die Taste release…

Du wolltest nach 5 Sekunden; du hast nicht gesagt dass es auch wieder aufhören soll :slight_smile:
Versuchs mal mit dem hier: Play a sound when key is pressed, stop when no longer pressing. - Blueprint Visual Scripting - Unreal Engine Forums

TL: It seems he intended to play after 5 seconds, and stop as soon as the button is released.