Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Posted by William Anugerah on February 6, 2017 at 10:22 am

    Hello and good day to all,

    This time I’d like to ask if anyone knows the script required to create a sort of “aim constraint” in After Effects.

    So what I mean is this: Two objects, when the “controller” object (red null) is moved, the yellow null object will rotate on its axis to orient itself towards the controller.

    Seems like it should’ve been simple but I can’t figure out how to make it work.

    Thank you in advance!

    Donutz Mar replied 6 years ago 3 Members · 2 Replies
  • 2 Replies
  • Kevin Camp

    February 6, 2017 at 8:32 pm

    for 2d layers, this should work:
    target = thisComp.layer("Null 1"); // set this to the layer to aim at
    p = position - target.position;
    radiansToDegrees( Math.atan2( p[1], p[0] ) )

    for 3d layers you can use lookAt() on the orientation of the layer:
    target = thisComp.layer("Null 1");// set this to the layer to aim at
    lookAt( position, target.position )

    Kevin Camp
    Art Director
    KCPQ, KZJO & KRCW

  • Donutz Mar

    September 16, 2017 at 7:38 pm

    Hi! This seems a good solution ☺

    https://vimeo.com/62314581
    https://aescripts.com/leemsanimationtools/

    Good luck!

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