A function that takes an actor’s world position and finds the closest point on a spline curve would be most useful. One can often get around it but it can demand quite a lot of work and it seems like a very useful function.
Thanks.
A function that takes an actor’s world position and finds the closest point on a spline curve would be most useful. One can often get around it but it can demand quite a lot of work and it seems like a very useful function.
Thanks.
Hi,
I see this post has several up votes but it is almost 2 years old. Is this something everyone is still interested in seeing implemented?
Also, if anyone would like to post their implementation of this functionality to help others; please feel free.
Cheers,
TJ
It’s not a implementation, but an approach analog to the Newton Algorithm for zero intersection :
location = actorsWorldPosition
pointA = getClosestSplinePoint
pointB = getSecoundClosestSplinePoint
currentDelta = Distance(pointA, location)
while(currentDelta > Threshhold) { // my Thresshold is 1
// get 2 extra Points between the outer Points
point1 = A
point2 = getPointOnPlineByDistance( 1/3 * (DistanceB-DistanceA) )
point3 = getPointOnPlineByDistance( 2/3 * (DistanceB-DistanceA) )
point4 = B
// check which 2 points are the closest to location, they have to be neigbors, thats given with catmul splines, don't worry
pointA = closest
pointB = secoundClosest
currentDelta -= Distance(LocationBetweenNewPoints, location)
}
This is just from my memory, don’t blame me for details. It also isn’t prefect, because it orients itself at the 2 closest spline points, in this example it’s not so cool:
We didn’t code a solution, we just didn’t overextend our tangents of the spline and used more spline points at critical positions
I think it would be useful still
I’d still vote for this.
At the time I was using splines for avatars’ movements on a map, not having this functionality was cumbersome. I can think of other use cases of course - a free-moving actor might need this for events that for whatever reason need to get attached to a defined path of travel at a certain time for instance.
What about this implemented function?
Reckon that’ll do the trick - thanks a bunch for the heads up! Awesome!