Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Spawn Objects of differing lengths uniformly along a Spline
#2
Hi,
Here is how I would have coded it:
(the following is pseudo code, but should be clear enough so you can easily implement the real thing)
Code:
float splineLength = yourSpline.Length;
float vehiculesLength = //the sum of all your vehicules' length;
float totalSpaceBetweenVehicules = splineLength - vehiculesLength;
Assert.IsTrue(totalSpaceBetweenVehicules  > 0); // don't forget to handle the case where this is not true
float perVehiculeSpacing = totalSpaceBetweenVehicules / (vehiculesCount - 1);
float currentDistance = 0;
foreach (var vehicule in vehicules)
{
   vehicule.CurvyController.AbsolutePosition = currentDistance;
   currentDistance += (vehicule.VehiculeLength + perVehiculeSpacing);
}
Note that I used AbsolutePosition instead of InitialPosition, because InitialPosition is deprecated in the latest Curvy version. If you want to stick to old Curvy versions, then you can use InitialPosition while setting Position mode to Absolute.
I hope this helps
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: Spawn Objects of differing lengths uniformly along a Spline - by _Aka_ - 06-19-2018, 05:31 PM

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_
  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_
  GO can't fit end of the spline GameDeveloperek4123 3 14 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: