-
almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped
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 turnspre = 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.
