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.
PLease help me!!
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.
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:
while((time-counter*thisComp.frameDuration>=0) && (thisComp.layer("Null 1").position.speedAtTime(time-counter*thisComp.frameDuration)==0)) counter=counter+1;
while((time+counter*thisComp.frameDuration<=thisComp.duration) && (thisComp.layer("Null 1").position.speedAtTime(time+counter*thisComp.frameDuration)==0)) counter=counter+1;
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) delta=1;
Hope that might help somebody.
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.
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.