Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to find a point a distance ahead on the spline?
#1
In my project, I have a SplineGroup. I am trying to step along the spline when it is created, and generate objects along it. However, I need to find a way to 'step' forward properly on the spline. I'm currently using the following code to do so, and it eventually 'locks up', or refuses to move further ahead. Meaning it will spawn about 4 or 5 collectables just fine - then the remaining 25 or so all generate at the exact same position, which isn't even a quarter of the way through the spline path.

So based on this - what is the correct way to get a point X distance forward on the spline?


Code:
private void genCollectables()
{
Debug.Log("--- Gen Collectables Begun");

float genTF = 0.871f;
for(int i = 0; i < 30; i++)
{
Vector3 genPosition = movementPathSplineGroup.Interpolate(genTF);
GameObject tempColChain = (GameObject)Instantiate(tempPrefab);

// Set Position
tempColChain.transform.position = genPosition;

// Set rotation to match the spline
tempColChain.transform.rotation = movementPathSplineGroup.GetOrientationFast(genTF);

float distBetweenPoints = Mathf.Abs(genTF - genPosition);
genTF = tfAtLastPoint + distBetweenPoints;
}
}



 
Reply


Messages In This Thread
How to find a point a distance ahead on the spline? - by DCalabrese - 06-06-2014, 06:20 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Spline Issue Leading to Unity Freeze Pankaj09 1 100 08-24-2026, 11:28 PM
Last Post: _Aka_
  Spline Spots from 2 samples. BitBlit 8 1,001 06-30-2026, 11:49 AM
Last Post: _Aka_
  Best way to duplicate a spline with an offset Kapistijn 8 2,368 04-12-2026, 03:18 PM
Last Post: _Aka_
  Control Point Interpolation Overrides. rickgplus 1 835 12-11-2025, 08:52 AM
Last Post: _Aka_

Forum Jump: