ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Link opacity to Null Position.

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam Høj
Link opacity to Null Position.
on Jan 3, 2014 at 9:59:48 am

Hi guys!

I've been trying to figure this one out this morning, and I seem to be stuck now..

I have a line of dots, and a Null that is above them.

I want each dot to have its opacity go from 25 -> 100, when the null is above it +- a value I can easily change.

All that have been worked out now, but I want it to fade from 25-100, but I cant figure out how...

I hope you can help me out!

Kind regards,

Adam

//Position//
ConPos = thisComp.layer("Controller").transform.position[0];
CircPos = transform.position[0];

//Opacity//
MaxOpa = 100;
MinOpa = 25;

//Controllers//
s = thisComp.layer("Controller").effect("Tolerance Slider")("Slider");

//EXPRESSION//

if (CircPos&gt;ConPos+s || CircPos&lt;ConPos-s)

{MinOpa}

else

{MaxOpa};


Return to posts index

George Goodman
Re: Link opacity to Null Position.
on Jan 3, 2014 at 4:31:05 pm

This should work. Put it in the opacity property of each shape layer. Make sure that the anchor point is in the center of the shape layers. It's assuming you're calculating the distance based on x value and using the entire width of a 1920 comp. It's taking the absolute value of the difference between the x position of the null object and the x position of the shape layer and basing it's opacity on that. So when the position difference is 0 - it's 100% opacity, when the position difference is 1920, the opacity is 25. You may want to play with the values, but that should be the basic idea.

distance = Math.abs(thisComp.layer("Null 1").transform.position[0] - transform.position[0])
linear(distance, 0, 1920, 100, 25)



"|_ (°_0) _|"

Sincerely,

George


Return to posts index

George Goodman
Re: Link opacity to Null Position.
on Jan 3, 2014 at 4:43:39 pm

Read that last post I made, but I think you should use this expression instead, it would be cooler. Add two slider controls to that null object and name them opacityMIN and opacityMAX. To start set opacity min at 25 and opacity max to 100. If you use this expression instead, you don't have to update every shape layer expression if you decide to change the values. Instead, you just change the numbers on the slider controls on the null object and all the expressions will auto update.

That junx would be tight.

distance = Math.abs(thisComp.layer("Null 1").transform.position[0] - transform.position[0])
linear(distance, 0, 1920, thisComp.layer("Null 1").effect("OpacityMAX")("Slider"), thisComp.layer("Null 1").effect("OpacityMIN")("Slider"))



"|_ (°_0) _|"

Sincerely,

George


Return to posts index


Adam Høj
Re: Link opacity to Null Position.
on Jan 5, 2014 at 10:38:22 am

Hi George.

Thanks for your suggestions. I posted the question to another forum, where I got this answer.

//EXPRESSION//

ease( Math.abs(ConPos-CircPos), 0, s, MaxOpa, MinOpa);


I combined that with your suggestion for the opacity sliders, and have a pretty sweet control object...


Return to posts index

Nick Hopkins
Re: Link opacity to Null Position.
on Jun 25, 2014 at 8:43:08 pm

Hey George,

I really like this set up, but I can't seem to get it to work with X AND Y values. Do you know of any way to control both with the null object? Great stuff!


Return to posts index

George Goodman
Re: Link opacity to Null Position.
on Jun 25, 2014 at 8:55:51 pm

This is untested, but I think it would do what you're looking for. Rather than just looking at the x distance from the null, it looks at the y distance also, and takes the total distance into account when determining opacity. In this case, I used the sliders on the Null again so that you can determine your own max and min opacity at any point.

xdistance=Math.abs(thisComp.layer("Null 1").transform.position[0] - transform.position[0])
ydistance=Math.abs(thisComp.layer("Null 1").transform.position[1] - transform.position[1])
totaldistance=xdistance+ydistance
linear(totaldistance, 0, 3000, thisComp.layer("Null 1").effect("OpacityMAX")("Slider"), thisComp.layer("Null 1").effect("OpacityMIN")("Slider"))


"|_ (°_0) _|"

Sincerely,

George

http://www.vimeo.com/georgegoodman
http://www.linkedin.com/in/georgefranklingoodman


Return to posts index


Nick Hopkins
Re: Link opacity to Null Position.
on Jun 25, 2014 at 9:05:47 pm

Works perfect, thank you so much


Return to posts index

Amy Young
Re: Link opacity to Null Position.
on Feb 25, 2017 at 10:50:18 pm

Thanks George! Very useful and succinct!


Return to posts index

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