FORUMS: list search recent posts

Cumulative Variable?

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Ocean Byrne
Cumulative Variable?
on Mar 20, 2012 at 10:10:56 pm

I want to create a variable - Cumulo - which adds the value of another parameter - Adder(which animates) - to itself on every frame.

So on:
frame 1 - Adder = 10 - Cumulo = 10
frame 2 - Adder = 10 - Cumulo = 20
frame 3 - Adder = 10 - Cumulo = 30
frame 4 - Adder = 20 - Cumulo = 50
frame 5 - Adder = 20 - Cumulo = 70

How do I write an expression to do that?
My final values will be much less user friendly to think about.

Thanks


Return to posts index

Dan Ebberts
Re: Cumulative Variable?
on Mar 20, 2012 at 10:26:02 pm

Expressions can't pass information from one frame to the next, so there aren't any persistent variables. The best you can do is base your calculation of the global time object, or do it the brute force way and create a loop that starts at time=0 (or the layer's in point) and re-creates everything that has happened on previous frames.

Dan



Return to posts index

Ocean Byrne
Re: Cumulative Variable?
on Mar 20, 2012 at 10:42:20 pm

So I dont think basing it on time will work for me, cause that doesnt account for the the various changes that Adder made over time.

So how would I go about creating this loop that looks at the history of Adder and calculates Cumulo on each frame?

Thanks for your help.


Return to posts index


Dan Ebberts
Re: Cumulative Variable?
on Mar 20, 2012 at 11:26:46 pm

Probably something like this (it depends on what Adder is):


Adder = thisComp.layer("Other Layer").transform.rotation;
f = timeToFrames(time);
Cumulo = 0;
for (i = 0; i <= f; i++){
t = framesToTime(i);
Cumulo += Adder.valueAtTime(t);
}
Cumulo


The value at each frame takes longer to execute than the frame before, so this may not be a good method for a long composition.

Dan



Return to posts index

Ocean Byrne
Re: Cumulative Variable?
on Mar 21, 2012 at 12:36:54 am

Thanks a bunch for your help Dan,

Took some tweeking, but I got it working:

Adder = comp("Shashkin").layer("Desert").effect("Form")("Flow Z");
f = timeToFrames(time);
Cumulo = 0;
for (i = 0; i &lt;= f; i++){
t = framesToTime(i);
Cumulo += (Adder.valueAtTime(t) / 30);
}
[750, Cumulo]


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]