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
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Keeping a fixed spline length jh092 3 16 02-21-2024, 06:25 AM
Last Post: Primrose44
  How could I get position in spline from "From" value in BuildRasterizedPath? Chanon 1 8 02-12-2024, 09:54 PM
Last Post: _Aka_

Forum Jump: