Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Text Stays Horizontal

  • Text Stays Horizontal

    Posted by Aaron Pozzer on September 7, 2011 at 1:23 pm

    after a quick search, I couldnt find any answers for this.

    I would like to have my text (or any object), stay horizontal in relation to the camera position/orientation. this only needs to work on the Z rotation channel. since the text is positioned to be laying on the ground, the x and y can stay static… i just need to keep it lined up on the z axis, as the camera is looked down the z onto it.

    thanks!

    Aaron Pozzer replied 14 years, 8 months ago 2 Members · 5 Replies
  • 5 Replies
  • Aaron Pozzer

    September 8, 2011 at 7:00 pm

    Dan has the answers even when he doesnt have the answers!

    https://www.motionscript.com/design-guide/auto-orient-y-only.html

  • Aaron Pozzer

    September 8, 2011 at 7:19 pm

    spoke too soon… this doesnt quite work. at least, doesnt work when applied to the zRot channel to keep the text lined up to screen horizontal.

  • Dan Ebberts

    September 8, 2011 at 7:36 pm

    I’m not sure this works in all cases, but give it a try:

    C = thisComp.layer(“Camera 1”);
    v = C.toWorldVec([1,0,0]);
    radiansToDegrees(Math.atan2(v[1],v[0]))

    Dan

  • Aaron Pozzer

    September 8, 2011 at 8:58 pm

    yes! thats the one! if i had to be super nit picky, the value the expression returns is a BIT off… only by a few degrees. im guessing this is probably just a result of the x and y rotation adding a bit of perspective or something that is not being accounted for in the expression. but its 100% better than having to do it by hand 🙂

    thanks dan.

    edit: ya i think thats the case because as the camera moves to a more head-on angle, that few degrees becomes less and less.

  • Aaron Pozzer

    September 9, 2011 at 1:12 pm

    after a bit of fiddling, it seems that its the yRot on the camera that gives the slightly off results. when the camera is down, close to the map/ground, and rotated to be looking towards the horizon, the more oblique the angle, the more off the returned result.

    im not sure if there is a proper way to correct for this in the script, but i did this…

    C = thisComp.layer("TRGT: Goal");
    v = C.toWorldVec([1,0,0]);
    rot = radiansToDegrees(Math.atan2(v[1],v[0]))

    rot -(thisComp.layer("TRGT: Goal").transform.yRotation/2)

    (the camera is animated with sure target, so i changed the c from looking at the camera, to looking at the target. doesnt seem to make a differnce in the results, but just fyi).

    i tried it without the /2, but that corrected by TOO much. so half seems to yeild better results, at least in this particular circumstance. its by no means a global fix, as it completely doesnt work on a different object earlier in the animation.

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