09-27-2020, 05:31 PM
In the following line:
spline.GetComponent<>(CurvySpline).Add(firstObject.transform.position, secondObject.transform.position);
the Add method takes local positions, and you are feeding it with global positions.
I would recommend you to use Curvy 7 or newer, and use the methods (Add, GetNearestPointTF, ...) that have an additional parameter called space and that allows you to define whether the input/output is in the local space or global one.
Also, instead of writing:
float nearestTf = spline.GetComponent<CurvySpline>().GetNearestPointTF(inversePositionOnSpline);
Vector3 positionForSphere = spline.transform.TransformPoint(spline.GetComponent<CurvySpline>().Interpolate(nearestTf));
You can write
float nearestTf = spline.GetComponent<CurvySpline>().GetNearestPointTF(inversePositionOnSpline, out Vector3 positionForSphere);
spline.GetComponent<>(CurvySpline).Add(firstObject.transform.position, secondObject.transform.position);
the Add method takes local positions, and you are feeding it with global positions.
I would recommend you to use Curvy 7 or newer, and use the methods (Add, GetNearestPointTF, ...) that have an additional parameter called space and that allows you to define whether the input/output is in the local space or global one.
Also, instead of writing:
float nearestTf = spline.GetComponent<CurvySpline>().GetNearestPointTF(inversePositionOnSpline);
Vector3 positionForSphere = spline.transform.TransformPoint(spline.GetComponent<CurvySpline>().Interpolate(nearestTf));
You can write
float nearestTf = spline.GetComponent<CurvySpline>().GetNearestPointTF(inversePositionOnSpline, out Vector3 positionForSphere);
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.