01-27-2021, 03:40 PM
Since it is still a basic question I'll reply here not to create another thread.
Basically, I want to get the closest control point for a given world position and then loop all the control points of a spline (in both directions). My problems start when the world transform is exactly on one of the control points.
Some snippets:
and then I can call
to get the nextSegment. The problem is when the nearestPointTF is equal to 1 and I have a spline with loop enabled. The method won't return me the correct next segment (I mean correct for my understanding).
The situation is even more complicated when I want to traverse it in reverse.
Are there any samples that I may be missing? Or maybe I am mixing some of the terminology and it leads me to weird situations?
Basically, I want to get the closest control point for a given world position and then loop all the control points of a spline (in both directions). My problems start when the world transform is exactly on one of the control points.
Some snippets:
Code:
var nearestPointTf = spline.GetNearestPointTF(transform.position, out var output, Space.World);
var nearestSegment = spline.TFToSegment(nearestPointTf);
and then I can call
Code:
var nextSegment = spline.GetNextSegment(nearestSegment);
to get the nextSegment. The problem is when the nearestPointTF is equal to 1 and I have a spline with loop enabled. The method won't return me the correct next segment (I mean correct for my understanding).
The situation is even more complicated when I want to traverse it in reverse.
Are there any samples that I may be missing? Or maybe I am mixing some of the terminology and it leads me to weird situations?