Activity › Forums › Adobe After Effects Expressions › Point towards expression
-
Point towards expression
Posted by Greg Howell on May 10, 2016 at 6:39 pmHi Guys,
Does anyone know an expression that will allow me to point a triangle at a circle? I need it to point towards it, wherever I move either of the shapes. I have an expression that does this, but not quite properly. Let’s say this triangle is a pointing hand. I need the hand to be parented to an arm. If I rotate the arm on it’s anchor point (the elbow), I need the hand to still be pointing at the circle. This wont work at the moment. Parenting the hand to the arm screws up the direction it’s pointing in.
Does any one know of a solution?
thanks,
Greg
Lukasz Pason replied 5 years, 9 months ago 4 Members · 13 Replies -
13 Replies
-
Greg Howell
May 10, 2016 at 7:28 pmactually, think of the anchor point as a shoulder, not an elbow. that’s probably less confusing.
-
Kalleheikki Kannisto
May 11, 2016 at 6:16 amI believe you need subtract the rotations of any parent objects from the point-at expression result. If it is just one parent object, subtract the rotation value of that object, if it is a chain, subtract the rotation values of all the parent objects.
You may need to add the rotation value of the object itself (“+ value”) to be able to rotate your pointing triangle in the right direction initially. And more so if you want to add additional movements to it.
-
Greg Howell
May 11, 2016 at 6:18 pmHi Kalle,
Thanks for your response. I’m not sure this worked, but I think I may of done it wrong. Do you have an expression I could copy please?
thanks!
-
Kalleheikki Kannisto
May 11, 2016 at 6:37 pmThe basic expression to add to the end after your auto-orient code would be
-(thisComp.layer("pickwhip parent layer here").transform.rotation)(and if it is parented several times, add the other parents at the end)
If that doesn’t do it, your set-up is different from what I visualize.
What is the expression that you currently have? How is it parented? Once or in a chain?
-
Dan Ebberts
May 11, 2016 at 6:53 pmTry this:
L = thisComp.layer(“circle”);
p1 = fromComp(L.toComp(L.anchorPoint));
v = p1 – anchorPoint;
value + radiansToDegrees(Math.atan2(v[1],v[0]))Dan
-
Greg Howell
May 11, 2016 at 7:13 pmHi Dan,
Where’s the bit in the expression that refers to the arm in which the hand is parented to?
-
Greg Howell
May 11, 2016 at 7:19 pmHi Kalle,
This is the expression i have at the moment. It also has a slider that it refers to, to offset it. this is used to calibrate it.
The expression is from the motion v2 plugin from mt.mograph…
calibrate = effect(“Rotation – Stare Calibrate”)(“ADBE Slider Control-0001”);
try {
diffx = position[0] – effect(“Rotation – Stare Target”)(“ADBE Layer Control-0001”)
.transform.position[0];
diffy = position[1] – effect(“Rotation – Stare Target”)(“ADBE Layer Control-0001”)
.transform.position[1];
if (diffx === 0) {
diffx = 1;
}
sign = 1 + (-1 * (diffx / Math.abs(diffx))) * 90;
radDegExp = 1 + radians_to_degrees(Math.atan(diffy / diffx));
value = radDegExp + sign + calibrate;
} catch (e) {
L = null;
}
Reply to this Discussion! Login or Sign Up