Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects to.world expression for pointing at a layer

  • to.world expression for pointing at a layer

    Posted by Greg Howell on October 18, 2020 at 1:18 am

    Hi,

    Using an expression, I can quite easily have layer A point to layer B, but if layer A is parented to a moving layer (layer C), it no longer works properly. How do I get around this?

    I think its something to do with a to.world expression. I dont know anything about this expression though. Does anyone have any ideas?

    thanks,

    Greg

    Greg Howell replied 5 years, 7 months ago 3 Members · 6 Replies
  • 6 Replies
  • Walter Soyka

    October 18, 2020 at 2:34 am

    Sure. toWorld is exactly what you want — it translates a point from a layer’s local space to world space.

    This expression should point one layer at another, irrespective of their parenting chains (ancestry?):

    lookAt(thisLayer.toWorld(thisLayer.transform.anchorPoint), thisComp.layer("Target").toWorld(thisComp.layer("Target").transform.anchorPoint));

  • Greg Howell

    October 18, 2020 at 2:55 am

    Hi Walter,

    Thanks for your help. Do I paste this in the pointers rotational value?, because it doesn’t seem to work..

  • Walter Soyka

    October 18, 2020 at 3:41 am

    It’s for the Orientation property.

  • Greg Howell

    October 18, 2020 at 4:02 am

    Do you mean the anchor point property?, because theres only an orientation property in 3d. This is 2d. I pasted it in, but it doesn’t point at the target. See attached.. thanks!

  • Dan Ebberts

    October 18, 2020 at 10:19 pm

    Probably like this rotation expression (you may have to add or subtract 90, depending on how you have your pointer set up):

    T = thisComp.layer("Target");

    v = T.toComp(T.anchorPoint) - toComp(anchorPoint);

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

  • Greg Howell

    October 18, 2020 at 10:23 pm

    This works perfectly. Thankyou!

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