Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link opacity to Null Position.

  • Link opacity to Null Position.

    Posted by Adam Høj on January 3, 2014 at 9:59 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>ConPos+s || CircPos<ConPos-s)

    {MinOpa}

    else

    {MaxOpa};

    Amy Young replied 9 years, 2 months ago 4 Members · 7 Replies
  • 7 Replies
  • George Goodman

    January 3, 2014 at 4:31 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

  • George Goodman

    January 3, 2014 at 4:43 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

  • Adam Høj

    January 5, 2014 at 10:38 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…

  • Nick Hopkins

    June 25, 2014 at 8:43 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!

  • George Goodman

    June 25, 2014 at 8:55 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

  • Nick Hopkins

    June 25, 2014 at 9:05 pm

    Works perfect, thank you so much

  • Amy Young

    February 25, 2017 at 10:50 pm

    Thanks George! Very useful and succinct!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy