- 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!
- 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, p ) )
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 )
KCPQ, KZJO & KRCW
Log in to reply.