The event is called repeatedly, and the delay node takes effect only once

Hi everyone, I create a custom event which contains a delay node. I call it repeatedly, expecting everything in the event can do the same number times as I call it.

Example:


906a5ed176970210a9d2b0e119ac39c8464236ff

Like the example, I click “P” five times in 2 seconds, and you can see it in image, print “Hello” five times, it is right.
But the result is only print “world” once. I hope it can also print five times. I want to know the reason of only print once and how to do I achieve the effect which I hope?

You’re starting the execution chain again, before it’s had a chance to complete.

There is no forking of background processes here.

The easiest way to get it to do what you want, is to spawn a blueprint which prints ‘hello’, and then prints ‘world’ 2 seconds later. ( then destroys itself )

Otherwise, you’d had to keep the requests in an array, with timer handles ( or something like that ).

1 Like

Maybe you can try making a integer variable that increases based on the number of times you press ‘P’ , then add your delay. Once the delay is finished use a for loop to print “World” using the integer variable then reset the variable after you finish printing.

Probably close to:

I originally thought that each call event was independent of each other, but in fact they are always using the same thing like static variables?

Pressing the key again, restarts the execution of that line.

1 Like

It seems like if an event needs a long time for work, and in fact, the external will call it frequently for a short period of time (Such as my example, call it again before it complete). Then, it will have problems.
Maybe I need to rethink how to use event in my project.
Thank you for you answer!

1 Like

You can hang an awful lot of stuff on an event, and it will all run in one frame, which is pretty quick :slight_smile:

It’s just when you start introducing ‘latency’, signified on nodes by the clock, that things work differently

image

1 Like