Activity › Forums › Adobe After Effects Expressions › Aim Constraint
-
Aim Constraint
-
William Anugerah
February 6, 2017 at 10:22 amHello 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 pmfor 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 pmHi! This seems a good solution ☺
https://vimeo.com/62314581
https://aescripts.com/leemsanimationtools/Good luck!
Reply to this Discussion! Login or Sign Up
Log in to reply.