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
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: 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
  Best way to duplicate a spline with an offset Kapistijn 8 1,360 04-12-2026, 03:18 PM
Last Post: _Aka_
Smile Constant speed along a spline? tfishell 1 657 11-13-2025, 11:32 AM
Last Post: _Aka_
  SplineController Ignores Follow-Up and Chooses Wrong Spline Josenildo 7 4,462 07-29-2025, 09:15 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 7 6,222 07-13-2025, 07:11 PM
Last Post: _Aka_

Forum Jump: