Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Rotation anchors
#4
Ok... I think I figured it out. I need to set the Spline.Orientation to static and then make sure the Z-rotation of the CP's are set to 0.

I want the flat spline path to stay  parallel to the ground plane (XZ), not to bank, even if the spline all over the place. 
For example, old "Slinky" toy was a flat spiral. Or a road twisting through the mountains (assuming they don't try to bank the curves for speed) is best flat, side-to-side across the road.

I will code this to see if this does it. If you know of a better or more proper way, please suggest.


Code:
        Vector3 localFinalPos = trackSpline.transform.InverseTransformPoint( worldPos );
        var cp = trackSpline.Add( localFinalPos, Space.World );
        var euler = cp.transform.rotation.eulerAngles;
        cp.SetRotation( Quaternion.Euler( euler.x, euler.y, 0 ) );
Seems to work!!
Reply


Messages In This Thread
Rotation anchors - by tairoark - 05-30-2022, 03:38 AM
RE: Rotation anchors - by _Aka_ - 05-30-2022, 04:52 PM
RE: Rotation anchors - by tairoark - 05-30-2022, 07:05 PM
RE: Rotation anchors - by tairoark - 05-30-2022, 08:07 PM
RE: Rotation anchors - by _Aka_ - 06-01-2022, 02:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Exclamation bad rotation aloriza 5 14 11-29-2023, 09:52 AM
Last Post: _Aka_
  Rotation issue with generator nicolaj.h.andersen@gmail.com 1 15 04-14-2023, 11:58 AM
Last Post: _Aka_
  Align to spline action and rotation Lupp_ 3 1,341 01-23-2021, 08:12 PM
Last Post: _Aka_
  Rotation of Curvy Spline Segment jh092 1 1,350 05-31-2020, 09:36 AM
Last Post: _Aka_

Forum Jump: