0

I've got Blueprint of my character where I spawn a bomb with a key. I try to limit number of bombs with NumOfBombs int variable. When bomb is spawned I subtract 1, when it explode after 2sec delay I add 1.

System is working if I wait those 2 secs. If I put within 2secs more than 1 bomb I get only +1 NumOfBombs.

Edit: Seems like it the same to my camera shake after delay. Maybe there can be just 1 delay at a time?

Any ideas why?enter image description here

I use Unreal Engine 4.9.1

Pimgd
  • 5,983
  • 1
  • 30
  • 45
Phantoms
  • 141
  • 3
  • 9

1 Answers1

0

Unfortunately, if the delay node is triggered during the delay, it is ignored. From the documentation for the delay node:

Calling again while it is counting down will be ignored.

It is irritatingly difficult to fix this generally in Blueprint (using re-triggerable delay just resets the timer, setting a timer will just reset the timer).

In this case, I assume after 2 seconds the bomb actor gets destroyed? In that case, I would bind to the On Destroyed event and use that to decrement your counter. This event will get fired once per bomb so it will be decremented the correct number of times.

This has the added advantage that if you change the lifetime of the bomb, you don't need to remember to update this blueprint to match the new length.

T. Kiley
  • 2,752
  • 21
  • 30