02-13-2014, 08:10 AM
Ok, I had a look. The problem is related to Unity's loading and initialization order. You didn't take that into account, so you've added the CP before the Spline initializes itself.
In general, before working with a spline from another script, do:
You don't need to wait for it in Start(), but then be sure to check CurvySpline.IsInitialized before working with the spline. See the docs here .
Cheers
Jake
In general, before working with a spline from another script, do:
Code:
IEnumerator Start () {
spline = splineObject.GetComponent<CurvySpline>();
while (!spline.IsInitialized)
yield return 0; // this waits until the spline is ready
// Do whatever you want...
}
Cheers
Jake