I am trying to create an arrow with a line in after effects. The start point is always static, the end point can be moved with sliders and on the end point there is a triangle pointing in the direction the line is pointing.
The line itself is no problem: I used the pen tool to create a path, used create nulls from path and added sliders to the null that controls the end point.
The triangle part is what I can't seem to figure out. On the rotation property of the function:
var p1 = thisComp.layer("Start").transform.position;
var p2 = thisComp.layer("End").transform.position;
radiansToDegrees(Math.atan2(p1,p2);
(Start and End are the Nulls controlling the path)
I assume atan2 is the proper approach in this scenario but Ae gives me an error and the result of the final line is NaN. Any help is much appreciated.
Late answer but try this:
p1 = thisComp.layer("Start").transform.position;
p2 = thisComp.layer("End").transform.position;
v = p2 - p1;
radiansToDegrees(Math.atan2(v[1], v[0]));
In your code there is a close parenthesis missing at the end, that's why the error.