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
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 14 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: