ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

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

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Russell Beyeralmost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped
by 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:



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.


Return to posts index

Chris WrightRe: almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped
by on 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
https://forums.creativecow.net/thread/227/16368#16396


Return to posts index

Russell BeyerRe: almost there with an expression to auto orient along a path properly but layer rotation is wrong when moving or stopped
by on Feb 3, 2016 at 8:24:15 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.


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]