Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to get Split Length to match spline segment length?
#2
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:

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();
        }
    }
Reply


Messages In This Thread
RE: How to get Split Length to match spline segment length? - by dromo - 07-21-2022, 11:31 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  snap to the curve created by the curvy splines segment points ShiroeYamamoto 3 11 04-02-2024, 02:24 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_

Forum Jump: