Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to duplicate a spline with an offset
#3
Thanks for the quick response.

I've implemented a custom solution, but I'm getting stuck on calculating the tangent.

Code:
private Vector3 CalculateOffset(CurvySplineSegment originalSplineSegment)
        {
            if (m_CurvySpline == null || originalSplineSegment == null)
                return Vector3.zero;

            Vector3 tangent = m_CurvySpline.GetTangent(originalSplineSegment.TF);
            Vector3 perpendicularTangent = Vector3.Cross(tangent, originalSplineSegment.transform.up);

            Vector3 offset = perpendicularTangent * m_Offset;

            Debug.DrawLine(originalSplineSegment.transform.position, originalSplineSegment.transform.position + (tangent * m_Offset), Color.yellow, 10.0f);
            Debug.DrawLine(originalSplineSegment.transform.position, originalSplineSegment.transform.position + (perpendicularTangent * m_Offset), Color.red, 10.0f);

            return offset;
        }

In the attachment you can see the yellow line representing the perpendicular. But I'm expecting a vector more like the purple one.
Am I doing something wrong to calculate the perpendicular? Or am I misinterpreting what the tangent actually is?

Thank you so much in advance!


Attached Files Thumbnail(s)
   
Reply


Messages In This Thread
RE: Best way to duplicate a spline with an offset - by Kapistijn - 02-02-2026, 03:37 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Generator gameobjects missing offset and rotated beewhale 5 418 08-30-2026, 07:51 PM
Last Post: beewhale
  Spline Issue Leading to Unity Freeze Pankaj09 1 201 08-24-2026, 11:28 PM
Last Post: _Aka_
  Connecting Multiple Spline Nodes Issue Ritesh Kadam 1 159 08-22-2026, 11:24 PM
Last Post: _Aka_
  Spline Spots from 2 samples. BitBlit 8 1,079 06-30-2026, 11:49 AM
Last Post: _Aka_

Forum Jump: