Delay node only runs the first time custom event is called, never runs again

This event is called every time you pick up a weapon, I did a lot of tests with print strings and I can see the first time it’s called it runs through perfectly, it loops when it needs to and the delay works just fine every time.

The Second time it’s called though it gets to the delay node and just stops. A print string right before the delay will get called but nothing after the delay will get called. I don’t get any errors or anything. I tried this same code with retriggerable delay but get the exact same outcome.

The delay node just completely stops the code, but only the SECOND time the event is called. WHY

If the delay hasn’t finished counting, if will ignore new calls. Once it’s finished, you can call it again and set a new delay.

1 Like

But isn’t that what a retriggerable delay is for, every time you call it it restarts the delay timer? Because retriggerables don’t work either.

Also I get what your saying with the delay ignoring new calls but I don’t see how that is relevant in this code, you call the event initially and then it loops until the event finishes by spawning a new actor. Once that happens the delay should work the next time it’s called right?

Hi there,
How are you calling that event Respawn Pickup? Are you using a “for each loop” or something?
If so, loop macros will not work with delays, so you need custom macros.

UE4 Tutorial - For Each Loop With Delay - YouTube

1 Like

Whenever you pickup an item on the ground the item is destroyed and this Respawn Pickup function is called.
The idea is that the item will respawn but only after a certain amount of time and only if the player is not nearby. The only loop is if the weapon is trying to respawn but the player is too close, the weapon will wait X seconds before checking player distance and potentially respawning

test with smaller and bigger value, you will get what you want to know.

I don’t really understand what you’re saying. I have put different values in the delay but it’s always the same thing.

The first time the Respawn Pickup is called it works perfectly, even if the branch is true it will loop the proper amount of times until it respawns and the loop ends. BUT, the second time that Respawn Pickup is called the code just stops running at that delay node.

Waaait, you’re saying that this code is in the object that’s being destroyed? Are you trying to use a latent function (delay in this case) after you call destroy on this actor?

4 Likes

For my weapon pickup I’m using Set Actor Hidden In Game.

But your comment does explain why my battery pickup didn’t work, I was destroying the actor on that one. Hehehe, whoops.

Turns out that the weapons that I was setting to hidden were also getting destroyed later on. That explains why it worked fine initially but not the second time.

It’s very helpful to take a step back from the code while someone else takes a look at it to point out all the obvious sh*t that Cleary won’t work.

Good teamwork guys.

1 Like