Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Change to Random Spline on End Reached Event
#6
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:

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.
Reply


Messages In This Thread
RE: Change to Random Spline on End Reached Event - by _Aka_ - 09-12-2021, 11:00 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 14 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: