Last active
March 31, 2025 17:01
-
-
Save Jered/55045ea5d98a7d3cd1a242aa938794d5 to your computer and use it in GitHub Desktop.
After Effects Auto-Orient Expression
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| cornerEase = 3; // sets the amount to look ahead and behind for gradual turns | |
| pre = position.valueAtTime(time-thisComp.frameDuration*cornerEase); | |
| post = position.valueAtTime(time+thisComp.frameDuration*cornerEase); | |
| delta = post-pre; | |
| if (delta[0] == 0 && delta[1] == 0) { | |
| // if there is no change in vector maintain the current heading | |
| rotation; | |
| } else { | |
| // use the vector direction to orient. Flip the Y to account for cartesian Y being up and AE Y being down | |
| radiansToDegrees(Math.atan2(delta[0],-delta[1])); | |
| } |
Author
Nine years later this came as a life saver. Thank you!
Wow! Glad it helped!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nine years later this came as a life saver. Thank you!