7 Replies Latest reply on Dec 1, 2017 12:57 AM by Benoit Sanson

# rotation flips 180° with Auto orient to path

Hi,

I'm animating a car using "auto orient along path." On one Frame, while turning around a corner, the car layer suddenly flips 180° around it's x-axis and back on the next frame. I know this kind of behavior from 3D Apps, where I usually fix the problem by defining an up-vector. But i can't figure out how to do this in AE.

Any help would be greatly appreciated.
• ###### 1. Re: rotation flips 180° with Auto orient to path
Not possible directly. You'd have to re-create the behavior with expressions and add a conditional test... I think Dan Ebberts has something on his site motionscript.com. Otherwise search AEnhancers.com. I can't point to a specific thread, but I'm reasonably sure you can find some older posts providing a solution.

Mylenium
• ###### 2. Re: rotation flips 180° with Auto orient to path

This is one of the eternal unsolved questions. I have years using AE and never found a solution. If there anybody that can help me, please.

Is the same issue. I import the motion path form illustrator and in the frames that I add manually, my object flips erratically. Why this happen! I have review if the path is correct and it is.

• ###### 3. Re: rotation flips 180° with Auto orient to path

This is called gimbal lock and it happens in any system that uses a two node camera. The solution is to lay out your project properly in the first place. Copying a path and pasting it to a motion path gives you motion in X and Y. This is where orient to path gets fouled up. The solution is add a 3D null to the comp, make your camera a child of the null, rotate the null in X 90º and then remove the null. Your motion path is now in X and Z and gimbal lock has gone away.

The other option is to attach your camera to a 3D null that is used as a dolly by parenting and then attach the camera's point of interest to a null that follows the same path as the camera but offset the null's motion in time by a few frames. This will give you the look ahead behavior that is normal human behavior when approaching a turn, We tend to look toward the direction of the turn before we actually get there where orient to path looks perpendicular to the path all the time.

• ###### 4. Re: rotation flips 180° with Auto orient to path

Here is the correct working code for Auto orient. I needed it a couple of yers ago and because After effects has glitches I wrote my own expression. It's for 2D layer but you can easy modify it for 3D. Add this to rotation property:

counter=1;

direction=-1;

while((time-counter*thisComp.frameDuration>=0) && (thisComp.layer("Null 1").position.speedAtTime(time-counter*thisComp.frameDuration)==0)) counter=counter+1;

if (time-counter*thisComp.frameDuration<0){

direction=1;

counter=0;

while((time+counter*thisComp.frameDuration<=thisComp.duration) && (thisComp.layer("Null 1").position.speedAtTime(time+counter*thisComp.frameDuration)==0)) counter=counter+1;

counter=counter+1;

}

counter=counter*direction;

pre = thisComp.layer("Null 1").position.valueAtTime(time+(counter-1)*thisComp.frameDuration);

post = thisComp.layer("Null 1").position.valueAtTime(time+counter*thisComp.frameDuration);

delta = post-pre;

if (delta[0] == 0) delta[0]=1;

Hope that might help somebody.

• ###### 5. Re: rotation flips 180° with Auto orient to path

Thanks for both posts. Very interesting. I think an expression could be the soulution. But I do not know what to change in it to make it works on a 3D layer. Maybe you can help me with that. I hope so.

thanks!!!

• ###### 6. Re: rotation flips 180° with Auto orient to path

Your solution is easy. Either rotate the motion path 90% in X  or parent the camera to a null and move the null. In AE, a camera at the default position is looking at X horizontally and Y vertically. Depth is Z. Point the camera straight up or straight down and you'll get gimbal lock. It will take you about 30 seconds to rotate your camera motion path 90 and then a few minutes to re-arrange your scene.

The best option that produces the most realistic camera moves is to animate the point of interest or attach the point of interest to a null and move the null around the scene also. That is what a camera operator would do. He would stand on a dolly and look through the lens and point the camera at what he was interested in getting in the frame. You're making this too hard. Make it simple with a dolly and a point of interest null or just add a null, parent your camera to the null, rotate the null 90 in x and then delete the null. Re-arrange your layers in Z space and you're good to go.

• ###### 7. Re: rotation flips 180° with Auto orient to path

Thanks a lot, your script is perfectly working (CC2018) !