07-21-2022, 11:31 AM
Here is an update on my issue:
I have come up with an alternative solution to getting the segment lengths and mesh lengths to be the same. I am passing the Input Spline Path module only two control points at a time, and getting the generator to only make a mesh between these two control points.
I loop over all control points in the spline this way, so that all the segments have a mesh made for them.
However, I have a new problem when using this method - all of the mesh colliders are positioned over the final segment in the spline. So if I have a spline with 5 segments, the mesh in the last segment has 5 colliders, and none of the other segments have any colliders. I have tried to override the code in the Create Mesh module, but nothing changes.
Is there a way to get each segment to have its own mesh collider in the correct position?
Here is the code I am using:
I have come up with an alternative solution to getting the segment lengths and mesh lengths to be the same. I am passing the Input Spline Path module only two control points at a time, and getting the generator to only make a mesh between these two control points.
I loop over all control points in the spline this way, so that all the segments have a mesh made for them.
However, I have a new problem when using this method - all of the mesh colliders are positioned over the final segment in the spline. So if I have a spline with 5 segments, the mesh in the last segment has 5 colliders, and none of the other segments have any colliders. I have tried to override the code in the Create Mesh module, but nothing changes.
Is there a way to get each segment to have its own mesh collider in the correct position?
Here is the code I am using:
Code:
public void SplineSegmentiser(CurvySpline theSpline)
{
inputSplinePath.Spline = theSpline;
float numOfSegmentsNeeded = Mathf.Ceil(theSpline.Length / rail_Segment_Length);
int segmentsNeededInt = (int)numOfSegmentsNeeded;
for (int i = 0; i < segmentsNeededInt; i++)
{
CurvySplineSegment fromCP = theSpline.ControlPointsList[i];
CurvySplineSegment toCP = theSpline.ControlPointsList[i + 1];
inputSplinePath.ClearRange();
inputSplinePath.SetRange(fromCP, toCP);
inputSplinePath.Refresh();
createMesh.Refresh();
rail_Path_Generator.Refresh();
createMesh.SaveToScene(fromCP.gameObject.transform);
createMesh.DeleteAllOutputManagedResources();
}
}