Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I find closest spline ?
#1
So I have a list of splines & I want to find the closest one (not necessarily the one with the closest control point)

Hi so how could I find the closest spline to a world position.








Thanks.
Reply
#2
Hi,

You will have to go through all the splines, compute the distance from your point for each one of them, and then selecting the spline with the shortest distance.
To compute that distance, you will have to use the CurvySpline.GetNearestPointTF(Vector3 localPosition, out Vector3 nearest).
Here is its documentation: https://api.curvyeditor.com/520/class_fl...69c49bc5a6

Let me know if you have any other questions
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
Hi thanks.
Ok so I understand that the TF value is a point along the spline, I'm not sure how I can calculate the distance with that. Is it possible to get a position vector in world space from a TF value ?
Reply
#4
In the method I linked to you, the second parameter, which is an out parameter, is the nearest point on the spline, in its local coordinates. Then use Unity's Transform.TransformPoint to transform the point to global coordinates.

About getting a point from a TF value, you can do that using CurvySpline.Interpolate(float tf) to transform a TF to a Vector3, in the local coordinates system of the spline.
Here is its documentation: https://api.curvyeditor.com/520/class_fl...2887988f39
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
Nice one thanks, I didn't need the TF value in the end just the local position.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile Constant speed along a spline? tfishell 1 318 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 3,683 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 5,156 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,869 06-07-2025, 09:44 AM
Last Post: _Aka_

Forum Jump: