Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity › Forums › Adobe After Effects › almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped

  • almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped

    Posted by Russell Beyer on February 3, 2016 at 4:46 am

    I need a little help fixing an expression I found that works way better than auto orient. The problem is the expression makes my layer rotate -180 degrees when moving and then snap back to it’s default rotation when stationary. It looks like this:

    9741_9734testcarfollowleader.aep.zip

    The layer should orient along path as normal when moving and hold it’s current rotation when stopped.

    cornerEase = 2; // 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]));

    }

    Thanks to Jared at mindfury.com for this expression. I followed his instructions but for the past hour I just can’t get this to work for me.

    Using Transform > Auto-Orient was making the layer twitch for no reason. I scoured the internet for hours trying to find someone with a similar Auto-Orient problem, tried a few things but with no luck. The above expression, if I can get it working, should solve all my problems.

    Russell Beyer replied 10 years, 7 months ago 2 Members · 2 Replies
  • 2 Replies
  • Chris Wright

    February 3, 2016 at 6:16 am

    lemme know if this helps, also post this in the adobe expression forum, so that dan ebberts can help you
    https://forums.creativecow.net/thread/227/16368#16396

  • Russell Beyer

    February 3, 2016 at 8:24 am

    Thanks Chris, I have had a look at that, it seems way too complicated for me to understand right now but I will have another look tomorrow. I feel like I am just missing something very small in my code, like one number just needs to be changed so it rotates along the path correctly. I have posted on Adobe forums too, hopefully someone can take a look.

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