Creative Communities of the World Forums

The peer to peer support community for media production professionals.

  • Aim Constraint

  • William Anugerah

    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!

  • 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
Viewing 1 - 3 of 3 posts

Log in to reply.

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