Skip to content

Instantly share code, notes, and snippets.

@Jered
Last active March 31, 2025 17:01
Show Gist options
  • Select an option

  • Save Jered/55045ea5d98a7d3cd1a242aa938794d5 to your computer and use it in GitHub Desktop.

Select an option

Save Jered/55045ea5d98a7d3cd1a242aa938794d5 to your computer and use it in GitHub Desktop.
After Effects Auto-Orient Expression
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]));
}
@MeisterDerMagie
Copy link

Nine years later this came as a life saver. Thank you!

@Jered
Copy link
Author

Jered commented Mar 31, 2025

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