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)
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
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?
Available for freelance work, feel free to reach out: toolbuddy.net
Please consider leaving a review for Curvy, this helps immensely. Thank you.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to modify Input GameObject's transformation properties by script. j95677 2 1,156 07-05-2024, 06:28 PM
Last Post: j95677
  Adjust radius of generated mesh via script? Shackman 1 917 03-26-2024, 01:12 PM
Last Post: _Aka_
  Adding Begining and End Mesh to Spline velikizlivuk 2 1,061 08-02-2023, 11:10 AM
Last Post: velikizlivuk
  Way to get objects script from generator Lupos 10 3,447 05-26-2023, 09:51 AM
Last Post: _Aka_

Forum Jump: