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
  Change to Random Spline on End Reached Event ricke 10 842 09-14-2021, 12:31 AM
Last Post: ricke
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 771 06-17-2021, 01:59 PM
Last Post: _Aka_
  Spot Generator resetting some values after Script compilation Mos Def 11 2,576 05-25-2021, 02:41 PM
Last Post: _Aka_
  Adding function to set GameObjecs in InputGameObject.cs Mos Def 2 912 04-01-2021, 03:43 PM
Last Post: Mos Def

Forum Jump: