09-11-2013, 10:33 AM
(09-11-2013, 10:14 AM)Jake Wrote: Ok, I had a look.
The "Set Rotation" option of SplineWalker and MoveAlongSpline custom actions work by setting rotation to Spline.GetOrientation(). This in fact builds the rotation to match the plane defined by the tangent and the up-vector. So to mute a certain axis from rotation, you'll need to zero out that axis from the tangent vector. E.g. to prevent rotation along the x-axis (i.e. tilting camera down/up), just zero out the y magnitude of the tangent and feed the LookRotation then:
(inside CurvyMoveAlongSpline.cs):
Copy&Paste the action into a new custom action (change the class name of course) and use that.Code:if (SetOrientation) {
Vector3 tan = mSpline.GetTangent(mTF,p);
tan.y=0; // no up/down tilting
go.transform.rotation = Quaternion.LookRotation(tan, mSpline.GetOrientationUpFast(mTF));
}
It's always a good idea to roll your own versions of SplineWalker or custom actions for stuff like that. As a benefit you can remove everything you don't need and safe a lot of IF-THEN calls. Perhaps you want to smooth out tilting instead of removing it etc... creating a custom controller is always the best and most performant way (if you're able to code, of course, but most parts can be copy&pasted).
That's the reason I make most of the API public. If a curve related piece of information is there, give the user access to it, you'll never know what he wants to do with it
Jake
Awesome stuff - thanks Jake!