# Animation Nodes: Wait x seconds, output 0, then output random number (for input to object instancer)

I've been trying to figure this out for a while, but I'm kind of stuck. I have an Object Instancer that duplicates an object a random number of times (between 5 and 30)

I want to have this number to stay constant for x amount of time before resetting (0) and then chooses a new random number.

I've gotten as far as to have the number of instances change every x frames (see attached Tree Node), but I can't figure out how to make it go to 0 before picking a new number.

Any help would be greatly appreciated.

• Have you give a look to Add/Animation then TimeInfo, Delay, Repeat? – lemon Mar 24 '18 at 12:10
• yes I tried messing around with that, but didn't get it to do what I wanted to. – oyztein Mar 25 '18 at 9:52

You can multiply the output of the Random Number Node with a value that is one for all frames except those that are multiple of $x$. We can detect if a value is a multiple of $x$ using modulo as follows: