animation nodes - delay frame update I’m using animation nodes to randomize texture coordinates when the frame changes. Its working well, but I’d like to have it only update every nth frame, like not change for 15 frames or so. I’ve tried using ‘min time difference’ but that doesn’t seem to have an effect.

I’ve got the node tree set to Auto execution, and ‘frame changed’ is also checked (always, tree, and property are off) the min time diff is set to .5 which seems to be .5 seconds. I would think this would make it update only every 15 frames (at 30 fps) however the texture is updating every frame… how can I delay the change?



I know this can't work as shown, but here is what I've got. The viewer on math node show the frame it should wait for: 20. but I'm not sure how to get that to happen. once it gets to 20 it should pick another random frame by adding the the current time with the random number output, and so on.
You don't need conditional executions to achieve this effect, what you need is a constant seed for every nth interval. For instance, if I floor divide the time by 10, the result will be zero for the first 10 frames, 1 for the next 10 frames, 2 for the next 10 frames and so on. If I used the result of the floor division as seed, the random offset will be constants for every 10 frames.



If you want the length of the intervals to be random, we may use an approach as follows. We will initialize a variable with some integer--say zero, at each execution, we will replace that variable by another random integer if some boolean is true, that boolean has some probability $P$ of being true. The value of the variable is then constant for some interval that depends on $P$ and changes if the boolean is true. The implementation may be as follow:



AN.seed if hasattr(AN, "seed") else 0


The above expression checks if AN has a variable called seed, if it has, it returns its value, if not, it restuns zero.

AN.seed = (new if y else original)


This expression sets the variable to the frame number if the boolean y is true. The boolean is true if the value of a random variable $\in [0,1]$ of a uniform distribution is less than 0.1 (meaning the probability of being true is equal to 0.1). The probable length of the intervals is inversely proportional to the probability $P$.

Now all you have to do is to use the value of that variable as seed for the random generator and everything should work as you expect it to.