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

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.
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?
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:

public void OnCPReachedHandler (CurvySplineMoveEventArgs e)
    // what CP have we moved over?

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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Controler Speed from metadata Bryan Thatcher 1 5 05-24-2024, 08:41 AM
Last Post: _Aka_
  How to get length starting from one spline to connected nth spline Dragon-3623 1 1 05-14-2024, 04:52 PM
Last Post: _Aka_
  Set Volume to the Volume Controller at Runtime pako88 2 10 04-08-2024, 03:26 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_

Forum Jump: