Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem adding control point after another control point via script
#6
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:

Code:
IEnumerator Start () {
spline = splineObject.GetComponent<CurvySpline>();

while (!spline.IsInitialized)
yield return 0; // this waits until the spline is ready

// Do whatever you want...
}
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
Reply


Messages In This Thread

Possibly Related Threads…
Thread Author Replies Views Last Post
  Get position of all control points for a spline gekido 1 2 2 hours ago
Last Post: _Aka_
  Adjust radius of generated mesh via script? Shackman 1 3 03-26-2024, 01:12 PM
Last Post: _Aka_
  Connections Problem Juton 3 14 03-06-2024, 10:41 AM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_

Forum Jump: