Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Counteracting parent’s rotation

  • Counteracting parent’s rotation

    Posted by Navarro Parker on May 22, 2013 at 9:05 pm

    I’m trying to keep a text layer always straight and horizontal, no matter how the parent rotates.

    Doing a simple negative rotation of the parent doesn’t work. In this example, the text layer is a sub-sub-sub-child of a chain of parents. And those parents each have a wiggle applied.

    How would I keep this 2d text layer always level?

    Gustavo Saliola replied 3 years, 7 months ago 5 Members · 9 Replies
  • 9 Replies
  • Dan Ebberts

    May 22, 2013 at 9:41 pm

    There are a couple of ways to do it. This is one:

    v = toWorldVec([1,0,0]);
    -radiansToDegrees(Math.atan2(v[1],v[0]))

    Dan

  • Navarro Parker

    May 22, 2013 at 10:35 pm

    It doesn’t look like it’s countacting the first parent’s rotation. When I parent the text layer initially, it gains a rotation of 18° (base on the parent).

    Then adding the expression makes it match up with it’s first parent 18° off. It’s not staying horizontal.

    I subtracted 18 at the end of the expression to fix it. But that’s more of a band-aid than a fix.

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

  • Dan Ebberts

    May 22, 2013 at 11:03 pm

    Ah yes–sorry, that won’t work for this situation.

    Try this one:

    L = thisLayer;
    r = 0;
    while(L.hasParent){
    r += L.parent.rotation;
    L = L.parent;
    }
    -r

    Dan

  • Jason Jantzen

    May 23, 2013 at 4:42 pm

    this got me wondering about an expression for the rotation on the orientation for a 3d layer. when he asked about keeping the subsubsub layer level, I was thinking of an orbiting type layer and THEN noticed they were all 2D. So I’m wondering Dan, what would you do for a layer parented to a layer’s orientation in 3D space to keep it facing the camera all the time but with an expression? I’ve wondered this in the past because when the objects move past the camera, I’d rather have them facing the direction they’re moving and not at the camera anymore.

    So basically layers orbiting one layer in 3d space using the orientation or even just one of the rotation parameters ALL facing the camera.

    Now that would be cool 🙂

    Jason Jantzen
    vimeo.com/jasonj

  • Quang Nguyen

    July 23, 2014 at 9:41 am

    Counteracting parent’s orientation/rotation in 3D is what I’m looking for. Can everyone help me continue on this problem?

  • Dan Ebberts

    July 23, 2014 at 9:53 pm

    I’m not sure if this is what you’re after, but try this Orientation expression:

    u = fromWorldVec([1,0,0]);
    v = fromWorldVec([0,1,0]);
    w = fromWorldVec([0,0,1]);

    sinb = clamp(w[0],-1,1);
    b = Math.asin(sinb);
    cosb = Math.cos(b);
    if (Math.abs(cosb) > .0005){
    c = -Math.atan2(v[0],u[0]);
    a = -Math.atan2(w[1],w[2]);
    }else{
    a = (sinb < 0 ? -1 : 1)*Math.atan2(u[1],v[1]);
    c = 0;
    }
    [radiansToDegrees(a),radiansToDegrees(b),radiansToDegrees(c)]

    Dan

  • Quang Nguyen

    July 24, 2014 at 6:52 am

    Oh my god Dan! You saved me on this! It worked like magic! Thank you very much! I am always your fan!

  • Quang Nguyen

    July 25, 2014 at 1:30 am

    Mr. Dan, would you help me with the position as well? I want the child to update its position while the parent rotates, scales and moves so that the child’s position remains unchanged in world space. I am making a particle system like the one you guided before to export it to my game.

  • Gustavo Saliola

    February 19, 2021 at 5:10 pm

    Thank you Dan! Twice in the same day, and many years later, you solve another one for my project needs. This time, an array of bubbles with photos that rotates like swirling as a group, but maintains it’s horizon individually.

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