# 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

## 1 Answer

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:

Th result of the previous node tree is as follows:

The number of objects briefly goes to zero and change into a random number every 10 frames.

• Hi Omar, thank you for your answer. I'm not sure I understand how to implement this to achieve what I wanted. I want to generate a random number for the object instancer, this number to stay constant for x amount of time, then briefly go to 0 before generating a new random number that stays constant for x amount of time and so on. Could you show me in this example blender file? dropbox.com/s/am0pg7767m3hpsy/clone_test.blend?dl=0 – oyztein Mar 25 '18 at 10:11
• @oyztein, you can store information in an additional (hidden) object, for instance in its vertices. From that I think you can easily control when the value is to be changed depending on the current frame. – lemon Mar 25 '18 at 10:30
• @oyztein I added a full example in my answer. Is it more clear now? – Omar Emara Mar 25 '18 at 14:11
• @OmarAhmad Yes I got it now, thank you so much! – oyztein Mar 25 '18 at 15:00