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
  Spline Issue Leading to Unity Freeze Pankaj09 1 428 08-24-2026, 11:28 PM
Last Post: _Aka_
  Connecting Multiple Spline Nodes Issue Ritesh Kadam 1 374 08-22-2026, 11:24 PM
Last Post: _Aka_
  Spline Spots from 2 samples. BitBlit 8 1,539 06-30-2026, 11:49 AM
Last Post: _Aka_
  Best way to duplicate a spline with an offset Kapistijn 8 2,947 04-12-2026, 03:18 PM
Last Post: _Aka_

Forum Jump: