Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions auto-orient layer towards another layer

  • auto-orient layer towards another layer

    Posted by Dan Fredley on January 3, 2011 at 8:57 pm

    I have two layers. I would like layer one to rotate towards layer two no matter where layer two goes on screen without any other parameters changing. In other words I would like to link the rotation of one layer to the position of another layer in Comp Space. Any ideas on how to do this? Thanks.

    Dan Fredley

    Dan Fredley replied 15 years, 4 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Fredley

    January 3, 2011 at 9:10 pm

    I did some research on how to find an angle between two points. This works well.

    radiansToDegrees(Math.atan2(transform.position[1]-thisComp.layer("Shape Layer 1").transform.position[1], transform.position[0]-thisComp.layer("Shape Layer 1").transform.position[0]))

    Dan Fredley

  • Dan Fredley

    January 3, 2011 at 9:18 pm

    Or as Dan Ebberts wrote in a previous post:

    L1 = thisComp.layer("Layer 1");
    L2 = thisComp.layer("Layer 2");
    p1 = L1.toWorld(L1.anchorPoint);
    p2 = L2.toWorld(L2.anchorPoint);
    delta = p2 - p1;
    radiansToDegrees(Math.atan2(delta[1],delta[0]));

    Dan Fredley

  • Kevin Camp

    January 3, 2011 at 11:04 pm

    if you happen to be using 3d layers, this would also work (in the orientation property). it will orient the layer so that the z-axis will always point towards the target layer.

    target=thisComp.layer("Layer 1");
    lookAt(target.position, position)

    Kevin Camp
    Senior Designer
    KCPQ, KMYQ & KRCW

  • Dan Fredley

    January 4, 2011 at 6:54 pm

    Good to know. Thanks!

    Dan Fredley

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