Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
When is it required to check if the spline / generator as initialized?
#1
As the title says, when is it required to check if the spline / generator as initialized?
I noticed in some threads and the documentation that its required to use a coroutine to check if the spline is finished initializing. What information is this for? Is it just for the very start?

Will this lead to occasional race condition errors otherwise? 

I'm making a level editor that uses splines and I instantiate splines for previewing and then placing walls. 

Should I wait for the spline to be instantiated before trying to add points/modify the spline at all?
Reply
#2
Hi
When instantiating objects via Unity's API, the Start method is not directly called (information based on my memories of tests done years ago). So if you want to use that object the same frame, it might not be initialized yet.The consequence can be that the spline is not refreshed yet for example, and it will be automatically refreshed by next frame. No race condition or any other serious issue, just potential delay.

Through the years, and with the enhancements on the code of Curvy Splines (and maybe some changes on the initialization code handling inside Unity itself?), those issues do not seem to be as problematic as before. I am hesitating about removing that part of the documentation (about using the coroutine to check the initialization), but I never took the time to do that. I need to do a thourough assessment of the code + tests before doing so.

So short answer: just use the curvy objects as you please, and if you witness that a spline is refreshed with a frame delay, then in your code check if the spline is initialized, and call refresh if it is.
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Keeping a fixed spline length jh092 3 14 02-21-2024, 06:25 AM
Last Post: Primrose44
  GO can't fit end of the spline GameDeveloperek4123 1 4 02-13-2024, 10:18 AM
Last Post: _Aka_
  How could I get position in spline from "From" value in BuildRasterizedPath? Chanon 1 6 02-12-2024, 09:54 PM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 8 02-06-2024, 01:28 PM
Last Post: DekoGames

Forum Jump: