If Boolean is True for a Certain Period of Time, Then Do Something.

The title is basically what I need. I’ve ran into this problem several times and I can’t seem to find a simple way to do this. It usually comes in the form of this:

What I want is something similar to this Retriggerable Delay node, but instead of resetting whenever it its triggered, it keeps counting down until it isn’t triggered, then the code continues. If the Boolean continues to be True, the node still doesn’t reset. If the Boolean is ever False, then it resets. Is there a way to do this?

Please select all of that in your picture and then press delete on your keyboard. Never do that again in Tick, please.
You’re welcome :slight_smile:

And now, let’s get to the implementation.

  1. Create Event/Function that will set your timer and probably change boolean. For example StartBooleanCheck.
  2. Create new Function named, for example, BooleanCheck.
  3. In StartBooleanCheck, call node SetTimerByFunctionName, and give it desired delay and a function name of BooleanCheck (image below).
  4. In the function BooleanCheck do your logic. For example:

if (some_boolean) { do some logic }

image

1 Like