I’m creating a filter with a text random selector.
My problem is - I can’t find a way to use the trigger once and then make sure that the trigger doesn’t affect anything for a few seconds before it starts working again.
In my case, the trigger is a smile, and I want to achieve the following effect:
When the user smiles, the text becomes visible.
The random selection process starts and stops after 2 seconds.
A repeated smile should not affect anything for 5 seconds after the user smiled for the first time.
After 5 seconds, the text will smoothly become invisible, and now the user can smile again to repeat everything again.
As you can see, the problem is that a smile always works as a trigger, so if I smile often, I will generate text again and again, and the animation that makes the text invisible is out of sync with its generation and everything turns into chaos.
How do I make the trigger (smile) not work for a few seconds after it was detected?
You can keep track of a “ready” state and use that to control the flow of events. Here, I’m making a delay value for that state, and setting the initial value with a pulse merge (the initial value in the delay value doesn’t actually work here). Then you can follow the flow of events from the “ready” receiver and you’ll see that the ready state gets reset after 5 seconds. The if/else patch will block the pulse event if ready is false. The animation patch on the bottom is just an example of something you might trigger with a pulse.
This is really an amazing and elegant solution, thank you so much!
I noticed that the 5-second animation only plays once, but if I connect the if/else output to the reset input of the 5-second animation, it will play again every time I click, and this cycle continues. Thank you again!
Adding some more info… this technique is called input debouncing. It’s a common technique in programming. Maybe I’ll pack it up and put it in the asset library.