ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Slider control updating value

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Crichton Meadows
Slider control updating value
on Aug 22, 2017 at 4:24:39 pm

I am trying to rotate an object with an expression but when I increment the rotation value it always resets on every frame, so it would be going back and forth, is there any way to save the value from frame to frame?

keyFrameVar = thisComp.layer("Black Solid 2").effect("Sound Keys")("Output 3")
value + keyFrameVar


Return to posts index

Andrei Popa
Re: Slider control updating value
on Aug 22, 2017 at 7:07:48 pm

If you want to create some sort of dependencie between frames, i think you should use time. something like
keyFrameVar = thisComp.layer("Black Solid 2").effect("Sound Keys")("Output 3");
frameNumber = time/thisComp.frameDuration;
value + keyFrameVar*frameNumber


this way you multiply keyFrameVar by the number of frames(like adding it for each frame)

Andrei


Return to posts index

Crichton Meadows
Re: Slider control updating value
on Aug 23, 2017 at 12:00:03 am

Unfortunately, I can't use time. I need the value to be an accumulation of over time of another input.
What I don't understand, is that the 'value' variable seems to always be set to the initial value at the first rendered frame.
When the expression returns a value, I expected that to be stored for example in the slider and when the next frame is rendered the 'value' variable would be the current value of the slider.


Return to posts index


Andrei Popa
Re: Slider control updating value
on Aug 23, 2017 at 8:06:31 am

After Effects expressions have no memory. Each frame they execute your code from zero. Nothing is saved over time except time. But i think that there is some workaround for your problem. You can execute the code for the whole addition each frame. The downside is that if you have a very long composition it will start running slow.

keyFrameVar = thisComp.layer("Black Solid 2").effect("Sound Keys")("Output 3")
frRate =1/ thisComp.frameDuration;
keyFrameSum = 0; //
for (i=1; i<time*frRate; i++) //going from frame to frame to add the value
keyFrameSum += keyFrameVar.valueAtTime(i/frRate); //adding the value that the keyFrameVar has for each frame
value+keyFrameSum


Andrei


Return to posts index

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