FORUMS: list search recent posts

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
David Cabestany
Link x,y position of the light sweep to the rotation of a null
on Jan 22, 2014 at 5:21:24 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?


Return to posts index

Dan Ebberts
Re: Link x,y position of the light sweep to the rotation of a null
on Jan 22, 2014 at 5:44:54 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



Return to posts index

David Cabestany
Re: Link x,y position of the light sweep to the rotation of a null
on Jan 22, 2014 at 7:17:53 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?


Return to posts index


David Cabestany
Re: Link x,y position of the light sweep to the rotation of a null
on Jan 22, 2014 at 7:29:32 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]