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
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
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
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
Question Volume Spots inter group distance Sacryn 1 3 02-27-2024, 04:08 PM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 10 02-06-2024, 01:28 PM
Last Post: DekoGames
  Newbie Question: Uniformly increase spacing between volume spots? SAMYTHEBIGJUICY 1 5 09-01-2023, 03:38 PM
Last Post: _Aka_

Forum Jump: