Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to duplicate a spline with an offset
#1
Hi,

What would be the best way to duplicate a spline with an offset? (as seen in the attachment).

I managed to spawn meshes with an offset (through generators), but I'd like to offset the spline itself without rasterizing it.
When selecting all the spline points and scaling them unfortunately doesn't have the wanted effect.

Any idea's?
Thank you so much in advance!


Attached Files Thumbnail(s)
   
Reply
#2
Hi,

There is no out of the box function that performs that type of duplication. However, you can create one by writing a script that:
- iterates through all the Control Points from the source spline
- for each CP, compute the position of the CP for the duplicated spline by translating the source position along the desired direction (perpendicular to the spline tangent)
- create destination CPs with the computed positions

Did this help?
Have a nice day.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#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
#4
Hi,
Add Space.World as the second parameter for the GetTangent call:
https://api.curvyeditor.com/FluffyUnderw...ine_Space_
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#5
Thank you for the response.

Unfortunately defining the space doesn't seem to affect the outcome.
I really feel like I'm missing something here. Any idea's?

Thank you so much in advance!

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

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

            Vector3 offset = perpendicularTangent * m_Offset;

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

            return offset;
        }


Attached Files Thumbnail(s)
   
Reply
#6
(02-05-2026, 09:33 AM)Kapistijn Wrote: Unfortunately defining the space doesn't seem to affect the outcome.
You are right. This is because of a bug I just discovered. The issue was introduced in version 8.10.0, and made the method ignore the second parameter in most cases. Sorry about this bug.

For now, please use the following definition of worldTangent to avoid the issue:
Code:
Vector3 worldTangent = m_CurvySpline.ToWorldDirection(tangent);
I am planning on releasing a fix in the upcoming week(s).

Does this solve your issue?
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply
#7
Yes, it works like a charm. Thank you so much for the excellent support! Smile


Attached Files Thumbnail(s)
   
Reply
#8
You are welcome.
If and when you feel like it, please leave a review for the asset, that helps a lot.
Have a nice day.
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Constant speed along a spline? tfishell 1 419 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 3,882 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 5,407 07-13-2025, 07:11 PM
Last Post: _Aka_
  Is there a way to get the position of each ControlPoint in spline by API? Chanon 1 1,934 06-07-2025, 09:44 AM
Last Post: _Aka_

Forum Jump: