Posts: 29

Threads: 10

Joined: Nov 2018

02-17-2019, 03:51 PM
(This post was last modified: 02-17-2019, 10:28 PM by dazz777.)
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.

Posts: 567

Threads: 35

Joined: Jun 2017

02-18-2019, 11:05 AM
(This post was last modified: 02-18-2019, 11:06 AM by _Aka_.)
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

Please consider leaving a

review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Posts: 29

Threads: 10

Joined: Nov 2018

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 ?

Posts: 567

Threads: 35

Joined: Jun 2017

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
Please consider leaving a

review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.

Posts: 29

Threads: 10

Joined: Nov 2018

Nice one thanks, I didn't need the TF value in the end just the local position.