FORUMS: list search recent posts

Random Rotation Based on Change In Color Expression

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ryan Morrison
Random Rotation Based on Change In Color Expression
on Mar 9, 2015 at 5:59:01 pm

The short version of what I'm looking to do is generate random rotation on a layer whenever there is change to the color value of the layer. This part I have figured out by using for a 10fps comp. In order to define "change" I'm just having after effects compare the color value of the layer at the current frame to the frame before it. The slider is creating a color value for the layer.

on rotation:
AA1 = effect("AA")("Slider").valueAtTime(time);

AA2 = effect("AA")("Slider").valueAtTime(time-.1);


The issue I'm running into is that whenever there is NO change between the current frame and the frame before it, the rotation value returns to the value it was at the VERY first frame. What I'd like it to do is rotate randomly within that range whenever there is change and when there is not change, the rotation should stay at whatever the last random value generated was.

Return to posts index

Walter Soyka
Re: Random Rotation Based on Change In Color Expression
on Mar 10, 2015 at 1:35:55 am

Expressions do not have any kind of memory that persists across frames; they are evaluated anew at each frame.

In other words, the calculated value on frame 1 does not overwrite the underlying value for future frames. Each frame is independent.

You have to either calculate the cumulative values of each frame in your expression (so frame 0 calculates the value for frame 0, frame 1 calculates the values for frames 0 and 1, frame 2 calculates the values for frames 0, 1 and 2, etc.), or you have to think of another way to make your expression a function of time.

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 All Rights Reserved