Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Link position of layer / effect to center of rotating object

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

    Posted by Patrick Grossien on February 21, 2015 at 3:28 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!

    Steve Bentley replied 8 years ago 4 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    February 21, 2015 at 4:58 pm

    Start with this and see if it gets you close:

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

    Dan

  • Patrick Grossien

    February 21, 2015 at 5:14 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.

  • Dan Ebberts

    February 21, 2015 at 5:54 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

  • Patrick Grossien

    February 21, 2015 at 7:36 pm

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

  • Harold Durnez

    April 11, 2018 at 9:40 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

  • Steve Bentley

    April 11, 2018 at 1:31 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.

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