04-17-2019, 10:36 AM
I forgot to say something important:
In the code above, I wrote:
This is misleading, because the first parameter of GetNearestPointTF needs to be the position in the local frame of the spline. In my code it is the position in the global (world) frame. The correct could would be:
The first version of the code worked because TrackSpline had a default transform, i.e the same transform than the world's, so the transformation did nothing. If TrackSpline's transform is modified, then the first version of the code would stop working correctly.
In the code above, I wrote:
Code:
TrackSpline.GetNearestPointTF(Controller.transform.position, out nearestPoint, out nearestSegmentStart, out nearestSegmentF);
Code:
TrackSpline.GetNearestPointTF(TrackSpline.transform.InverseTransformPoint(Controller.transform.position), out nearestPoint, out nearestSegmentStart, out nearestSegmentF);
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.