Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link x,y position of the light sweep to the rotation of a null

  • Link x,y position of the light sweep to the rotation of a null

    Posted by David Cabestany on January 22, 2014 at 5:21 pm

    I have 84 layers, each with a light sweep applied that fakes a reflection as the layer rotates on the y axis. The rotation is controlled by a null to which all 84 layers are parented. The null always rotates in the same direction, so the degrees are constantly increasing, the speed and duration of each layer’s rotation is likely to change so I’m trying to link the position of the light sweep to the rotation keyframes of the null so when I need to revise the speed and duration later after client revisions I don’t have to also tweak the sweep keyframes.

    I tried

    r=thisComp.layer(“rot”).transform.yRotation;
    x=linear(r,0,90,2700,1720);
    y=linear(r,0,90,1640,880);
    [x,y];

    But then the sweep position is still all the time, basically I don’t know how to rewrite the expression to account for the ever increasing rotation value.

    Can anyone help me to write an expression for this?

    David Cabestany replied 12 years, 7 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    January 22, 2014 at 5:44 pm

    Hard to say for sure, but it might be that you just need to change the first line to this:

    r=thisComp.layer(“rot”).transform.yRotation%360;

    so that the rotation resets to zero every 360 degrees.

    Dan

  • David Cabestany

    January 22, 2014 at 7:17 pm

    Thanks Dan, it partially worked. The first rotation from -90 to 0 works ok, but then nothing happens. If multiply the 360 x -1 then it’s the second rotation the one working, this one goes in the opposite direction.

    Is there a way to have the expression work in both directions?

  • David Cabestany

    January 22, 2014 at 7:29 pm

    Thanks Dan, it partially worked. The first rotation from -90 to 0 works ok, but then nothing happens. If multiply the 360 by -1 then it’s the second rotation the one working, this one goes in the opposite direction.

    So I tweaked the expression to this:

    yRot=thisComp.layer(“rot”).transform.yRotation;

    if
    (yRot<0)
    {
    r=thisComp.layer(“rot”).transform.yRotation%360;
    }
    else
    {
    r=thisComp.layer(“rot”).transform.yRotation%360*-1;
    }
    x=linear(r,-90,0,2700,1749);
    y=linear(r,-90,0,1640,880);
    [x,y];

    And apparently it works, I haven’t tested it extendedly but by scrubbing the timeline seems to be doing the trick.

    Thanks again.
    David.

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