Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using events to slow down or speed up a Spline Controller
#1
Hi,

How do I trigger certain actions when a Spline Controller reaches a CP?

I tried reading CurvyDefaultEventHandler documents, but they are quite brief and don't go into typical usage scenario examples.

I want a Spline Controller to change its speed when it reaches certain Control Points on a curve. I tried to use the Event system of the Spline Controller but got a little lost on what to write in my script and how to hook up the events. The event system looks similar to how buttons work in the Unity 5 UI but I can't say I'm too familiar with that either.

Could someone give some hints on how to write a script that stores various speeds and then feeds them into the Spline Controller when certain CP's are reached?

Any help would be highly appreciated.
Reply
#2
I posted this thread a couple of days ago, and there isn't a reply.

I purchased this asset only because of this claim: * Extensive documentation & API Reference

I love extensive documentation & API Reference.

But this isn't extensive at all. At all. How do I choose a CP? Do I just make a public GameObject and drag the CP there? How do I trigger an event when a SplineController reaches this CP? Can I only call events from last or first CP? If so, why?
Reply
#3
You posted yesterday, not a couple of days ago...anyways:

The OnCPReachedEvent is called everytime a controller moves over a CP. So you don't choose for which CPs it's called. Instead your event handler decides if you need to do something. And in fact it's working exactly like uGUI events (both rely on UnityEvents)

The CurvyDefaultEventHandler class shows some examples you can right plug into a controller event (especially the debug methods are useful for testing). All methods are present both as a class member or a static member. To use the former, you'll need to drag the CurvyDefaultEventHandler component to the controller GameObject, this will create a class object.

There isn't much special about events in general. You create a method and bind it to an event (by code or in the editor). Then this method will be called (much like Update() is called by Unity etc...).

So to simplify the example from the docs, create the below method in one of your MonoBehaviours, drag it to some GameObject and connect it to the OnCPReached event of the SplineController:

Code:
public void OnCPReachedHandler (CurvySplineMoveEventArgs e)
{
    // what CP have we moved over?
     Debug.Log(e.ControlPoint);
}

Does that help?
Reply
#4
Thank you very much for taking the time to explain this. I get it now that you explained it.
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Curvy Spline mover is jerky BlankMauser 5 68 08-16-2019, 09:31 PM
Last Post: _Aka_
  Camera wobbles on too long spline (100km+) Vectorvision 10 269 08-01-2019, 12:35 PM
Last Post: _Aka_
  Closest point From a Ray (a line), to the spline UsernameHed 5 168 07-31-2019, 03:57 PM
Last Post: _Aka_
  Follow Up Spline Issue JHulse95 8 314 07-25-2019, 02:36 PM
Last Post: _Aka_

Forum Jump: