Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Camera Rotation Does Not Match Spline Node Rotation
#7
(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):
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));
            }
Copy&Paste the action into a new custom action (change the class name of course) and use that.


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 Wink

Jake

Awesome stuff - thanks Jake! Big Grin
Reply


Messages In This Thread

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best way to duplicate a spline with an offset Kapistijn 7 663 02-07-2026, 07:59 PM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 495 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,065 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 5,632 07-13-2025, 07:11 PM
Last Post: _Aka_

Forum Jump: