FORUMS: list search recent posts

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

FAQ   •   VIEW ALL
 almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped on Feb 3, 2016 at 4:46:08 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:

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.

 Re: almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stoppedon Feb 3, 2016 at 6:16:57 am

lemme know if this helps, also post this in the adobe expression forum, so that dan ebberts can help you