Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Auto-orient without Auto-Orient Along Path

  • Auto-orient without Auto-Orient Along Path

    Posted by Lord Scales on June 24, 2007 at 7:35 pm

    Hi there! I have noticed Auto-Orient Along Path does not changes the rotation value of the layer, and sometimes I miss it. So, to fix this, i created this expression for the rotation of a 2D Layer:

    var t = position.valueAtTime (time + thisComp.frameDuration); vec = position – t;

    radiansToDegrees (Math.atan2 (vec[1], vec[0]))

    The problem is that it only works when the layer is moving. I used a lot of if/else trying to correct but I just wasted time. So I need some help to solve this problem.

    Thanks!

    Dan Ebberts replied 18 years, 10 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    June 24, 2007 at 8:05 pm

    If you want to calculate the world rotation of a 2D auto oriented layer (“Layer 1”), you can do it this way:

    L = this_comp.layer(“Layer 1”);
    V = L.toWorldVec([1,0]);
    radiansToDegrees(Math.atan2(V[1],V[0]));

    Dan

  • Lord Scales

    June 24, 2007 at 9:13 pm

    That’s perfect!
    Just one thing:
    toWorldVec([1, 0])
    means that only X axis will be converted?

  • Dan Ebberts

    June 24, 2007 at 9:29 pm

    Yes. Converting the x axis gives you everything you need to calculate the rotation.

    Dan

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