ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Hunter Hempen
Auto Orient expression to use for path layer? (Don't need built in AE option)
on Oct 1, 2018 at 3:43:41 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
-----


Return to posts index

Dan Ebberts
Re: Auto Orient expression to use for path layer? (Don't need built in AE option)
on Oct 1, 2018 at 6:00:10 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



Return to posts index

Hunter Hempen
Re: Auto Orient expression to use for path layer? (Don't need built in AE option)
on Oct 1, 2018 at 7:34:31 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
-----


Return to posts index


Dan Ebberts
Re: Auto Orient expression to use for path layer? (Don't need built in AE option)
on Oct 1, 2018 at 7:57:01 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



Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2018 CreativeCOW.net All Rights Reserved
[TOP]