Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expression to point a layer Rotation towards null

  • Expression to point a layer Rotation towards null

    Posted by Mac Lad on October 4, 2017 at 6:34 pm

    Hello Gurus,
    I m trying to figure out an expression to point my layer (which is a shadow in it of dots) Rotation toward null object as I need to animate the null from left to right.

    1.png
    This is my Main Comp with dots and Shadows

    2.png
    this is my shadow layer (All shadow are seperated)

    Anchor point of Shadow Layers is at the upper left corner of each layer so that it can be rotated around dots

    Is guys there any way to point this layer towards null object animating as I defined above or anywhere in the comp ?

    Mac Lad replied 8 years, 9 months ago 2 Members · 5 Replies
  • 5 Replies
  • Walter Soyka

    October 5, 2017 at 10:06 am

    Use this expression on the rotation properties of your shadow layers. Change the word CONTROL here to match the name of your shadow-caster layer.

    lookAtLayer = "CONTROL";
    L = thisComp.layer(lookAtLayer);
    p = L.toComp(L.anchorPoint);
    d = thisLayer.toComp(anchorPoint) - p;
    d[0] = (d[0]==0)?1:d[0];
    rotation + radians_to_degrees(Math.atan(d[1]/d[0])) - 90*d[0]/ Math.abs(d[0]);

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Mac Lad

    October 5, 2017 at 10:21 am

    That really works man !! Awesome, thanks for the help.
    I did try with dan’s shadow expression but that didn’t help me for the separate layers

  • Mac Lad

    October 8, 2017 at 8:41 am

    Is it possible to change the scale of the shadow layers depending upon the distance from the null?
    for instance:
    if my Control layer is at the top left corner then the scale of shadow layer at bottom right corner will be zero but the scale of the closest layer to the source is 100%. Just like a ramping

  • Walter Soyka

    October 9, 2017 at 9:29 am

    [Mac Lad] “Is it possible to change the scale of the shadow layers depending upon the distance from the null?”

    Sure.

    Add four Slider Control effects to your CONTROL layer, and name them and set their values as follows:
    minDistance 0
    minDistanceScale 100
    maxDistance 1000
    maxDistanceScale 0

    The put this expression on the scale property of your shadow layers:
    L = thisComp.layer("CONTROL");
    maxDistance = L.effect("maxDistance")("Slider");
    maxDistanceScale = L.effect("maxDistanceScale")("Slider");
    minDistance = L.effect("minDistance")("Slider");
    minDistanceScale = L.effect("minDistanceScale")("Slider");

    distance = length(L.toComp(L.anchorPoint), thisLayer.toComp(thisLayer.anchorPoint));
    scaleFactor = linear(distance, minDistance, maxDistance, minDistanceScale, maxDistanceScale) / 100;
    [value[0] * scaleFactor, value[1] * scaleFactor]

    Again, update the name CONTROL as necessary for your comp. You can adjust the values of the slider controls to tune the effect to your liking.

    Walter Soyka
    Designer & Mad Scientist at Keen Live [link]
    Motion Graphics, Widescreen Events, Presentation Design, and Consulting
    @keenlive   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Mac Lad

    October 10, 2017 at 12:39 pm

    Its working awesome!!
    thank you so much for the help… Ur genius 🙂

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