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
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: