ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Link position of layer / effect to center of rotating object

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Patrick Grossien
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!


Return to posts index


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

Start with this and see if it gets you close:

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


Dan



Return to posts index

Patrick Grossien
Re: Link position of layer / effect to center of rotating object
on 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.


Return to posts index



Dan Ebberts
Re: Link position of layer / effect to center of rotating object
on 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



Return to posts index

Patrick Grossien
Re: Link position of layer / effect to center of rotating object
on Feb 21, 2015 at 7:36:21 pm

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


Return to posts index

Harold Durnez
Re: Link position of layer / effect to center of rotating object
on 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
facebook.com/fullhd.co.za
behance.net/HaroldDurnez
vimeo.com/harolddurnez


Return to posts index


Steve Bentley
Re: Link position of layer / effect to center of rotating object
on Apr 11, 2018 at 1:31:26 pm

The expressions always go on the attribute you want to alter. So selecting the rotation parameter of the layer and then under the Animation menu selecting "add expression" will place the default expression on that attribute - the default just refers to what the layer is already doing. You can then select the line of code and erase it and type your own or pickwhip to have AE generate the code for you.

But you might have a simpler time of it. What about just making the null a child of the pendulum and moving the null to the end? The null will be moved by the rotation on the pendulum you animate, but the null will move out where the arc is transcribed.


Return to posts index

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