[Closed] Flipping axis – scripted path constraint
Hello
For the sake of learning I’m scripting a point dummy to follow a spline (like the path constraint).
I’m using the lengthInterp method found in Common Shape Methods to get a position a fraction along the curve’s total length. I use the lengthTangent to get the tangent vector at this position.
Getting the point dummy to move along the spline and aligning its z-axis to the tangent vector of the spline at the current position works fine. The problem is that the x-axis and y-axis sometimes flips. I assume this happens because there is some rotation around the z-axis of the point dummy. So I guess my question is: Is there some way to force no rotation around the z-axis of the dummy?
My script controller code:
finalMatrix = Matrix3
posMatrix = transMatrix (lengthInterp thePath (F/100))
rotationMatrix = MatrixFromNormal (lengthTangent thePath (F/100))
finalMatrix = rotationMatrix*posMatrix
return finalMatrix