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
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 278 06-17-2021, 01:59 PM
Last Post: _Aka_
  Spot Generator resetting some values after Script compilation Mos Def 11 1,175 05-25-2021, 02:41 PM
Last Post: _Aka_
  Adding function to set GameObjecs in InputGameObject.cs Mos Def 2 485 04-01-2021, 03:43 PM
Last Post: Mos Def
  Error while making prefab having curvy Generator script User2200 3 665 03-15-2021, 07:16 PM
Last Post: _Aka_

Forum Jump: