Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Making shape layer rotate to follow a null’s position

  • Making shape layer rotate to follow a null’s position

    Posted by Tom Nichols on April 23, 2015 at 10:45 pm

    Hi

    I need to use and expression to create an animation of a magnetic field attraction. So i have a series of small rectangle shape layers and would like them to follow a null around the screen always pointing at it.

    I want the rectangles to rotate on there own anchor point towards the null.

    I figured it would be something equivalent to a point of interest that i could attach to the null and therefore create the attraction.

    Like this magnet style:

    If I could have a couple of pointers that would be great.

    Thanks,
    Tom

    Tom Nichols replied 11 years, 4 months ago 2 Members · 2 Replies
  • 2 Replies
  • Frank Feijen

    April 24, 2015 at 12:32 pm
  • Tom Nichols

    April 25, 2015 at 4:00 am

    Thanks Frank for that but it doesnt quite fit my needs.

    This is my base equation:

    Line = length(toWorld(anchorPoint), thisComp.layer(“Null 1”).transform.position);
    delta = toWorld(anchorPoint) – thisComp.layer(“Null 1”).toWorld([0,0,0]);
    radiansToDegrees(Math.atan2(delta[0],-delta[1]))

    But i need it to react so that the further away it is from the X and Y axis the more accurate the direction of line is. And vice versa.

    So i extended it to this:

    YNull = length(toWorld(anchorPoint), thisComp.layer(“Null 1”).transform.yPosition);
    XNull = length(toWorld(anchorPoint), thisComp.layer(“Null 1”).transform.xPosition);
    Line = length(toWorld(anchorPoint), thisComp.layer(“Null 1”).transform.position);
    delta = toWorld(anchorPoint) – thisComp.layer(“Null 1”).toWorld([0,0,0]);
    radiansToDegrees(Math.atan2(delta[0],-delta[1]))*(Math.atan2(ease(YNull,740,850,3,1), ease(XNull,390,500,3,1)))

    But now it will not follow my Null layer correctly. I will attach a picture below of both expressions results.

    You may notice a grey opacity and that is where the lines should be to fit the design.

    BASE EXPRESSION:

    EXTENDED:

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