Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Auto orient path on shape layer

  • Auto orient path on shape layer

    Posted by Lionel Vicidomini on March 22, 2015 at 11:32 am

    Hello there,

    I’m trying to do something that sounds very simple to do but which is not (to me, at least)
    I have a shape layer with a stroke, an offset path and a trim path. The trim path animates the line. To the line I attached an arrow shape with a simple polygon with 3 points (so, a triangle). The triangle is following exactly the line thanks to the old trick and copying the vector path of the stroke to the position parameter of my triangle.
    Now I need the triangle to auto orient along that position path. Of course I could use the old trick of retrieving the orientation from a null objet with auto orient on.
    But I don’t want to do that, I want every thing to be contained inside a simple and unique shape layer.
    So I used this expression to the rotation property of the triangle :

    vecSpeed = content("Group 1").transform.position.velocity;
    radians = Math.atan2(vecSpeed[1], vecSpeed[0]);
    radiansToDegrees(radians)+90

    Which works fine except that the angle snaps at the beginning and the end of the animation, when the velocity is equal to 0.

    I tried to solve this problem with if/else expressions, trying to block the value to the frame before the last keyframe when the velocity is equal to 0, but that exceeds my level of knowledge.

    Anyone has an idea to solve this ?

    Here is the aep file

    8673_animatedarrowcs6.aep.zip

    Dan Ebberts replied 11 years, 5 months ago 2 Members · 1 Reply
  • 1 Reply
  • Dan Ebberts

    March 22, 2015 at 3:48 pm

    Try this:

    p =content(“Group 1”).transform.position;
    t = Math.min(Math.max(time,p.key(1).time+.001),p.key(p.numKeys).time);
    vecSpeed =p.velocityAtTime(t);
    radians = Math.atan2(vecSpeed[1], vecSpeed[0]);
    radiansToDegrees(radians)+90;

    Dan

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