Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Layer points to another layer with delay?

  • Layer points to another layer with delay?

    Posted by Kevin Snyder on July 7, 2018 at 5:18 am

    I’m using this code so that a layer rotates towards a parent.

    Is there a way to add a delay in frames to the rotation?

    L1 = thisLayer;
    L2 = Null_01;
    p1 = L1.toWorld(L1.anchorPoint);
    p2 = L2.toWorld(L2.anchorPoint);
    delta = p2 - p1;
    follow = radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Kevin Snyder replied 7 years, 9 months ago 3 Members · 4 Replies
  • 4 Replies
  • Kalleheikki Kannisto

    July 7, 2018 at 8:37 am

    A simple way to achieve this is to add another null which follows the position of the original null with a delay and calculate the rotation value based on the second null. Delay with valueAtTime():

    delay = .25;
    thisComp.layer("Null_01").transform.position.valueAtTime(time-delay);

    Kalleheikki Kannisto
    Senior Graphic Designer

  • Kevin Snyder

    July 15, 2018 at 3:20 pm

    Thank you, Kalleheikki. That sounds like a good way to make it work. I appreciate it.

    Kevin

  • Alex Printz

    July 16, 2018 at 2:12 pm

    This will take e.g. 99 frames (or whatever you set to t) and use the positions that the values were at at that time to calculate the delta. Adjust as necessary to get the result you want (maybe drop the t for L1(thisLayer)?


    t = time-framesToTime(99);
    L1 = thisLayer;
    L2 = Null_01;
    p1 = L1.toWorld(L1.anchorPoint,t);
    p2 = L2.toWorld(L2.anchorPoint,t);
    delta = p2 - p1;
    follow = radiansToDegrees(Math.atan2(delta[1],delta[0]));

  • Kevin Snyder

    July 19, 2018 at 2:55 pm

    Alex,

    Thank you for the expression. I appreciate it. It’s nice to get it all on one layer.

    Kevin

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