09-03-2021, 09:29 AM
(09-02-2021, 11:03 PM)blabz2007 Wrote: But the real problem is Spline.Length isn't 30 - you can see that on line 45 - Debug.LogWarning.That's normal: all your CPs have 0 coordinates on x and y. So the only relevant coordinate is Z. Your first CP has a Z of 0. Also your setup gives for each CP a Z coordinate bigger than its previous one. So under all those circumstances, the length of your spline is the Z coordinate of your last CP, which is 30 - Z coordinate of the previous CP.
Here is a variation of your code that does maintain the length of the spline to 30
Code:
int rnd = Random.Range(1, 5);
float lastUsedZ = 0;
for (int i = 1; i < rnd; i++)
{
lastUsedZ = lastUsedZ + i * 4.0f;
Spline.Add(new Vector3(0, 0, lastUsedZ));
}
// Create last Control point
Spline.Add(new Vector3(0, 0, lastUsedZ + 30 - Spline.Length));
If your spline has always the same length, then the problem I explained in my previous post is no more.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.