04-15-2019, 01:13 PM
Hi,
In the Infinite Track scene, you have multiple Curvy Generators that each generates the mesh of a section of the track. The section's start and end is defined by the StartCp and EndCp of the Input Spline Path of the generator.
I hope this helped
In the Infinite Track scene, you have multiple Curvy Generators that each generates the mesh of a section of the track. The section's start and end is defined by the StartCp and EndCp of the Input Spline Path of the generator.
Code:
//First, we find the index of the Control Point starting the segment the ship is on
int nearestSegmentStartIndex;
{
float nearestSegmentF;
CurvySplineSegment nearestSegmentStart;
Vector3 nearestPoint;
TrackSpline.GetNearestPointTF(Controller.transform.position, out nearestPoint, out nearestSegmentStart, out nearestSegmentF);
nearestSegmentStartIndex = TrackSpline.ControlPointsList.IndexOf(nearestSegmentStart);
}
//Then, we find which CurvyGenerator is generating the mesh that includes the found Control Point
foreach (CurvyGenerator curvyGenerator in mGenerators)
{
InputSplinePath inputSplinePath = curvyGenerator.FindModules<InputSplinePath>(true).Single();
int startCpIndex = TrackSpline.ControlPointsList.IndexOf(inputSplinePath.StartCP);
int endCpIndex = TrackSpline.ControlPointsList.IndexOf(inputSplinePath.EndCP);
if (nearestSegmentStartIndex >= startCpIndex && nearestSegmentStartIndex < endCpIndex)
Debug.Log("The ship is on the mesh generated by " + curvyGenerator.name);
}
I hope this helped
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.