Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Opacity relative to Proximity

  • Opacity relative to Proximity

    Posted by Benjamin Parker on September 8, 2015 at 11:36 am

    Hi,

    Say I had a Beam strung between two Nulls, is it possible to effect the beams opacity depending upon how close the two NUlls are ( not working from fix points but proximity)? and if so, is it possible to constrain the effect over a set distance? For example Null1 and Null2 are 500px apart they can move 450px closer with no effect but once they are within the 50px area the opacity drops?

    Many thanks

    “I believe our adventure through time has taken a most serious turn.”

    Miguel De mendoza replied 10 years, 8 months ago 2 Members · 1 Reply
  • 1 Reply
  • Miguel De mendoza

    September 8, 2015 at 12:35 pm

    Try this expression on the opacity:

    pivot1 = thisComp.layer("Null 1").transform.position;
    pivot2 = thisComp.layer("Null 2").transform.position;
    vector = pivot2 - pivot1;
    vLength = Math.sqrt(vector[0]*vector[0] + vector[1]*vector[1] )
    limit = 500;

    if(vLength > limit) {
    v = 100;
    } else {

    v = vLength /( limit/100)
    }

    value - v;

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