ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Link position of layer / effect to center of rotating object

FAQ   •   VIEW ALL
 Link position of layer / effect to center of rotating object on Feb 21, 2015 at 3:28:04 pm

Hi guys,

I'm trying to link the position of an effect to the center of a swinging object in a second layer.
aka fix a lens flare to a swinging lamp

So I have a rotation expression on the lamp layer. And the flare on a second layer.
How can I grab the center point of the lamp layer through it's rotation?
Because position and anchor point aren't animated, only rotation.

(The position of the flare effect moved by hand is 2000,255 if that is needed somehow)

Don't know how to get this started at all :(

Thank you a ton!

 Re: Link position of layer / effect to center of rotating objecton Feb 21, 2015 at 4:58:47 pm

L=thisComp.layer("lamp");
L.toComp([L.width,L.height]/2)

Dan

 Re: Link position of layer / effect to center of rotating objecton Feb 21, 2015 at 5:14:20 pm

Dan, you're the man! It looks spot on (no pun intended ;) ).
Thank you so much.

Just that I understand how this works:
When I grab the info from the layer, it always refers to it's actual position on the comp?
Because I would've guess that width and height are static values.

 Re: Link position of layer / effect to center of rotating objecton Feb 21, 2015 at 5:54:30 pm

>...I would've guess that width and height are static values.

They are, but [width,height]/2 represents the center of the layer in the layer's own coordinate space (relative to the layer's upper left corner). toComp() converts that value to comp coordinates.

Dan

 Re: Link position of layer / effect to center of rotating objecton Feb 21, 2015 at 7:36:21 pm

Ah ok, that clarifies it! Thank you a ton!

 Re: Link position of layer / effect to center of rotating objecton Apr 11, 2018 at 9:40:19 am

Dammit, I'm still a little lost here..
Where do these expressions get applied to..?

I believe I'm trying to achieve something similar.
I'm trying to link a (Joystick N Sliders) Control to a shape which has only rotation expression. i.e. a Ball with anchor point way up, pendulum swinging left & right.
I'd like my Null to trace the position of the swinging path created by the Rotation expression of Ball layer.

Thanks guys, hope you can help!
H

Harold JM Durnez
harold@fullhd.co.za
http://www.fullhd.co.za
behance.net/HaroldDurnez
vimeo.com/harolddurnez