Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Smoothing rotation of auto-orient along path

  • Smoothing rotation of auto-orient along path

    Posted by Mike Foran on September 16, 2019 at 6:20 pm

    I have an object moving along a 2D path with auto orient turned on. The path has several 90° angles, which predictably cause the object to instantly rotate to match. I’m looking for an expression that will replace Auto-Orient that can smooth this rotation out, so the spreads out over x period of time. Anyone know how I could do this?

    Mike Foran replied 5 years, 9 months ago 2 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    September 16, 2019 at 6:57 pm

    Maybe something like this:


    f = 2; // number of frames before and after to average
    v = [0,0];
    for (i = -f; i <= f; i++){
    v += position.velocityAtTime(i*thisComp.frameDuration + time);
    }
    v /= (f*2+1);
    a = Math.atan2(v[1],v[0]);
    radiansToDegrees(a)

    Dan

  • Dan Ebberts

    September 16, 2019 at 7:09 pm

    Oh yeah, you’d also turn off auto orient.

    Dan

  • Mike Foran

    September 16, 2019 at 7:25 pm

    After all these years I am still in awe of your mastery. Works like a charm. Thanks so much Dan!

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