Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Add Volume to the Volume Controller Dynamically
#3
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.

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
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Messages In This Thread
RE: Add Volume to the Volume Controller Dynamically - by _Aka_ - 04-15-2019, 01:13 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Replace deform mesh on volume spots Kokoriko49 1 2,282 06-09-2025, 06:49 PM
Last Post: _Aka_
  Filling a closed spline dynamically rickgplus 1 2,119 04-16-2025, 08:56 AM
Last Post: _Aka_
Photo Volume Spots problem with spacing Bond007 3 2,479 01-20-2025, 12:27 PM
Last Post: _Aka_
  Duplicate Volume references become null joebain 5 3,144 11-18-2024, 10:46 AM
Last Post: joebain

Forum Jump: