Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closest Spline & control points loop in both directions
#7
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:
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?
Reply


Messages In This Thread
RE: Beginner's questions - Closest spline & closest point on spline - by nehvaleem - 01-27-2021, 03:40 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Best way to duplicate a spline with an offset Kapistijn 8 1,355 04-12-2026, 03:18 PM
Last Post: _Aka_
  Control Point Interpolation Overrides. rickgplus 1 527 12-11-2025, 08:52 AM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 655 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,457 07-29-2025, 09:15 PM
Last Post: _Aka_

Forum Jump: