ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Use % of distance travelled between position to control opacity

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Rob McDougall
Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 10:34:53 am

Hey guys,

I've got about 90 shape layers which I'd like to fade off before they hit their last position keyframe - they only have 2 position keyframe.

I tried digging around on the forums, and modifying some bits I found, but I'm coming up blank.

This is not working:

driver = content("Rectangle 23").content("Rectangle Path 1").position;
k1 = 1;
k2 = 2;
p=content("Rectangle 23").content("Rectangle Path 1").position;
t1 = p.key(k1).time
t2 = p.key(k2).time


linear (driver, t1, t2, 0, 100);


What I'd like to have happen is on Position Keyframe 1, Opacity to be set to 100%, and by Keyframe 2, opacity to be 0%.

I figured Linear would be perfect for this, but I'm not sure how to address the keyframes - I'm also seeing an issue where I can get a "1" for keyframe 1, and a "2" for keyframe 2, which I can remap from 0-100% with a linear, but this just jumps from 0 to 100.

Any help would be gratefully received!


Return to posts index

Dan Ebberts
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 1:25:37 pm

I haven't tested it, but I think it would be like this:

p=content("Rectangle 23").content("Rectangle Path 1").position;
t1 = p.key(k1).time;
t2 = p.key(k2).time;
linear (time, t1, t2, 100, 0);


Dan



Return to posts index

Tomas Bumbulevičius
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 1:27:28 pm

Hey Rob,

assuming you are applying this expression to opacity property, just update your 'linear' with the following:

linear (time, t1, t2, 0, 100);

Most likely you will have to swap 0 and 100 between to have it as linear (time, t1, t2, 100, 0), but you will get an idea.

Interpolation works by taking 'control' parameter (in this case its time), and interpolating its values range (from t1 to t2) to property where you are applying it (in this case, opacity).

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index


Rob McDougall
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 1:54:34 pm

Got it - thanks both. I had a bit of a misunderstanding regarding the control parameter - I thought I should be pointing it at at the keyframe source, but of course I'm doing that with t1 and t2.

Thanks!


Return to posts index

Rob McDougall
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 2:54:14 pm

If I could impose on your for one more thing…

I want to paste this across multiple object, so I'd like the position property I'm referencing to be relative to the shape it's contained within - like using index-1 to address the layer above on a regular layer.

However, I can't figure out how to use propertyGroup to address this. I'm trying

p=thisProperty.propertyGroup(3).content("Rectangle Path 1").position;

to no avail. Do you know what I'm doing wrong here?


Return to posts index

Dan Ebberts
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 3:09:09 pm

I think you're on the right track. Try propertyGroup(2) .

Dan



Return to posts index


Rob McDougall
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 3:15:20 pm

Gents,

I am most appreciative!

Unfortunately, index-1 holds no sway on shape layers, but propertyIndex (3) got me there. I'd gone right round the houses with this. I'll have to do some further reading!


Return to posts index

Tomas Bumbulevičius
Re: Use % of distance travelled between position to control opacity
on Jun 12, 2019 at 3:10:32 pm
Last Edited By Tomas Bumbulevičius on Jun 13, 2019 at 6:07:33 am

Rob, something like this should make it to work.



thisComp.layer(index-1).content("Rectangle 23").content("Rectangle Path 1").position;

EDIT. Haha, for the second time, second after Dan! :D Just this time different approaches. Unless you are trying to achieve something differently - this indexing works as expected when duplicating.

Find out more:
After Effects Tutorials: motion design, expressions, scripting.
Boxer - Dynamic Text Boxes Template with a Live Preview


Return to posts index

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