09-12-2021, 11:00 AM
Hi
The infinite loop is due to the controller still being on the end of the spline when you change its spline, triggering yet another end reached event. What you have to do is to put the controller at the start of the spline when you change its spline:
Also, when you call Instantiate, the instantiated object does not have its Start called right away. This is the normal behaviour from Unity. To avoid any possible issue, and out of safety, I manually called Start on the instantiated spline. I modified SetPath() as follow:
I hope this helped
If and when you feel like it, please leave a review for the asset, that helps a lot
Have a nice day
The infinite loop is due to the controller still being on the end of the spline when you change its spline, triggering yet another end reached event. What you have to do is to put the controller at the start of the spline when you change its spline:
Code:
private void PathEndReached(CurvySplineMoveEventArgs arg0)
{
_controller.Position = 0;
SetPath();
}
Also, when you call Instantiate, the instantiated object does not have its Start called right away. This is the normal behaviour from Unity. To avoid any possible issue, and out of safety, I manually called Start on the instantiated spline. I modified SetPath() as follow:
Code:
private void SetPath()
{
if (attackPaths.Any())
{
currentPath = attackPaths[UnityEngine.Random.Range(0, attackPaths.Count - 1)];
if (currentPath != null)
{
_controller.Spline = Instantiate(currentPath);
_controller.Spline.Start();
}
}
}
I hope this helped
If and when you feel like it, please leave a review for the asset, that helps a lot
Have a nice day
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.