This content has been marked as final. Show 7 replies
Sorry if it's a silly question, but is there any reason why the layer's auto-orient function is unsuitable for the task?
You might try using lookAt position value at time. If you set your layer to 3D you can apply the following expression to Orientation.
lookAhead = thisComp.layer("Master Null").effect("lookAhead")("Slider");A slider control is added to a master null to control how far ahead or behind the current position the layer will point.
To keep the layer square to the scene you'll have to rotate it on y 90º.
This gives you more control over the orientation than orient to path does. I hope it helps.
>I guess 0.0 != -0.0 and -0.0 < 0.0 ? Any ideas how to resolve this?
It's a precision problem. Apart from your code being otherwise sort of *eek*, a 1 frame look ahead is not that much once you come to think of it. Depending on the actual speed, especially on the corners, where the positional difference might be insufficient to determine a criteria, this could pose a problem. Also you may wish to round your values instead of operating on the subpixel precision level as you do currently.
Thanks for all your replies.
I just tried auto-orient along path, and it looks promising, but I can't get the same side of the layer to face the same direction on each leg of the motion path. In other words, if I set auto-orient, and at time=0 I set the layer so that it is oriented correctly towards the camera by using Y and Z rotation, when it makes a 90 degree turn, the layer disappears because it's edge is now facing the camera.
I also just tried the lookAt() function, and it works fine, but it's being affected by the negative zeros so that only at certain times is the layer facing the camera correctly (it flips back and forth somewhat randomly).
The motion path is just a rectangle.
I forgot to mention that if you don't want a 3D layer to flip over when it changes direction from left to right you must make the motion path in the x z plane and not in the default x y plane. You then move the camera to the top and have it shoot down.
This applies to both the lookAt() expression and orient to a path in 3D.
That made it work better(auto-orient now changes the rotation corectly when turning a corner), but for some reason it still flips the wrong direction during random frames when traveling along a straight motion path. If I leave the paths as auto-bezier instead of switching to linear, the layer kind of "leans" around the turns.
This is kind of odd. I don't like it when things are non-deterministic...
Eulers v. Quarternions again, I suppose. If you check the value readouts, I'm sure at these frames the orientation completely changes its values in the opposite direction. So you'd probably have to create a "stable" solver with custom expressions. Might not be worth the effort, so why not simply convert the expression to keyframes and remove the offending parts (assuming your path does not change anymore)?