Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Auto Orient expression to use for path layer? (Don’t need built in AE option)

  • Auto Orient expression to use for path layer? (Don’t need built in AE option)

  • Hunter Hempen

    October 1, 2018 at 3:43 pm

    I’m fully aware there’s a simple Auto Orient context menu for paths, but I’m attempting to build from scratch.

    I used Dan’s amazing expression to tie a shape layer to a shape path via the Trim Paths End property as follows:

    e = thisComp.layer("Stroke Thing").content("Shape 1").content("Trim Paths 1").end;
    valueAtTime((e/100)*2)

    This works great, and can easily slide my layer along said path now. The next step I can’t figure out is a separate expression just to keep the layer properly auto oriented to the path. I did try the built-in context menu orient, but to no avail. It obviously needs just one more little expression added somewhere on that shape layer.

    —–
    Too bad she won’t live! But then again, who does?
    -Gaff
    —–

  • Dan Ebberts

    October 1, 2018 at 6:00 pm

    Assuming you have the latest version of AE, it would probably be something like this:

    pct = thisComp.layer(“Stroke Thing”).content(“Shape 1”).content(“Trim Paths 1”).end/100;
    t = thisComp.layer(“Stroke Thing”).content(“Shape 1”).content(“Path 1”).path.tangentOnPath(pct);
    radiansToDegrees(Math.atan2(t[1],t[0]));

    Dan

  • Hunter Hempen

    October 1, 2018 at 7:34 pm

    Thanks Dan, as usual works like a charm.

    For the sake of anybody reading this, can you explain a bit of the math behind that additional expression. I think tangentOnPath and radiansToDegrees seem fairly obvious, but what’s pct equal necessarily?

    —–
    Too bad she won’t live! But then again, who does?
    -Gaff
    —–

  • Dan Ebberts

    October 1, 2018 at 7:57 pm

    pct is just a variable representing the current percent of travel along the path, normalized to be between 0 and 1.0. That’s what tangetOnPath expects in order to give you the tangent value at that point.

    Dan

Viewing 1 - 4 of 4 posts

Log in to reply.

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