Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding OnSwitch event via Script
#1
Hello, I am struggling with adding an OnSwitch event to my Spline Controller via script.

what i tried :
Code:
  private void Init()
        {
        

            CurvySplineMoveEvent curvySplineMoveEvent = new CurvySplineMoveEvent();
            curvySplineMoveEvent.AddListener(OnSwitch);

            controller = gameObject.AddComponent<SplineController>();
            controller.OnSwitch = curvySplineMoveEvent;

        }

        private void OnSwitch(CurvySplineMoveEventArgs args)
        {
            Debug.Log("switch!");
        }
Reply
#2
Hi
Here is how to do it:
controller.OnSwitch.AddListener(EventHandler);
with EventHandler being a method with the following signature:
void EventHandler (CurvySplineMoveEventArgs argument)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
Thank you.
I tried it that way and my method didn't get called, the OnEndReached method however gets called.

Did I missunderstood it? I thought if you have 2 Splines connected OnSwitch would get called.
Reply
#4
Sorry, that's not when that event is raised. Here is the corrected documentation that hopefully will avoid confusion.
"Event raised while switching splines. Splines switching is done via the SwitchTo method."
If you want to know if a controller reached a connection, use the OnCPReached, and check in it if the reached CP has a Connection (controlPoint.Connection)
Did this help?
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
  OnEndReached event firing twice WesTheDev 1 3 01-13-2022, 10:07 AM
Last Post: _Aka_
  How to send event to generated game object upon ControlPoint deletion? toxicfrog 8 184 12-03-2021, 02:02 PM
Last Post: _Aka_
  Change to Random Spline on End Reached Event ricke 10 976 09-14-2021, 12:31 AM
Last Post: ricke
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 811 06-17-2021, 01:59 PM
Last Post: _Aka_

Forum Jump: