How to stop a delay?

Here’s a test method which shows the basic idea that I’m trying to do.

Basically, I have several print statements that play within 5 seconds of eachother. If “Bool” is set to false then the print statements stop. What I’m trying to do now is stop this function and then replay it from the beginning. The problem is that if I set the booleans to false right after hello2 appears and then call the function again, since the delay is still going, hello3 will still appear. So is there a way to just stop a delay and reset everything?

I can’t answer your question directly, I don’t even know if you can stop a delay node, but maybe I can help you set something else up? What are you trying to do with this functionality?

The print statements are meant to be functions separated by a delay. The branch basically allows it to be stopped at any point. The problem is resetting this. If I reset it while the first delay is going then it’s fine since the delay will be reset but if it’s reset while the second or third delay is going, since the boolean’s would still be true, it would continue to run from that point while also running from the beginning. I want to be able to completely stop and then reset from the very beginning.

You can use this code:

And change the bool with:


I’m just wondering what this does. The print statement represents a function call and each print statement is a different function call. Also while my example may have had 5 seconds between each call, in my actual code, each delay is different. Could this be used as a general way to stop a delay?

Ah, to be fair, you didn’t say that… :slight_smile: I’ll come back in a while…

So you can do this:

where each of the macros looks like:

Just in case someone stumbles upon this, you can solve it with a macro that simulates the set timer node + timer handler behavior.

Basically you can use a delay “handler” property (a GUID). The macro creates an ID and updates the handler before calling the actual delay. Once the actual delay completed, the macro checks if the ID of the handler is still the same, and fires the “Completed” pin of the macro. The key thing here is to pass the ID as reference in the inputs of the macro.

You can think of it as a delay node + a boolean branch as next node, with a bool property that you set somewhere to prevent the execution of the next nodes.

Side note, technically, the actual delay node won’t stop, but the macro hides this behavior.

This is the macro (I created it in the level blueprint but you should use a macro library),

and this is the usage