Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Custom connection controller help
#1
Hi, so I'm trying to make my gameobject  have a Connection custom selector so it can decide what spline to take at a junction. I've had a look in the documentation & read this :

Use Custom behavior: define your own connected splines selecting logic. You can do that by setting an instance of a class inheriting from ConnectedControlPointsSelector.

       Basically I have not got a clue how to do  this.

How would I go about doing this, Id really appreciate it if someone could give me some step by step instructions, it seems like my level of coding is   fairly basic.



Thanks in advance.
Reply
#2
Hi,

There is a class called ConnectedControlPointsSelector. You inherit from this class, and override its unique abstract method. Here is an example:

Code:
   using System.Linq;
   using UnityEngine;

   class Example : ConnectedControlPointsSelector
   {
       public override CurvySplineSegment SelectConnectedControlPoint(SplineController caller, CurvyConnection connection, CurvySplineSegment currentControlPoint)
       {

               return connection.ControlPointsList.Last();         

       }
   }

This example selector always chooses the last control point in the list of connected control points.

Then, you create an object in your scene having the Example script attached to it.
Finally, in your controller's inspector, you set "At connection, use" to "Custom", and then select the object created earlier in the field "Custom Selector"

Please let me know if you still have any question.

Have a nice day
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
Hi, thanks for the quick reply, I'll try that tomorrow.
Regards
Reply
#4
Ok so I get that 

 
Code:
return connection.ControlPointsList.Last();


makes the controller go to the last spline ( & last can be exchanged for first ) but can I get it to select a spline by name or tag or something.


Regards.
Reply
#5
That was just an example. It's up to you to make your own logic depending on your needs, using Unity's API. Here you can find the documentation about the properties to get the Name and Tag of a game object: https://docs.unity3d.com/ScriptReference/GameObject.html
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
I know how to get the Name & tag of a Gameobject in Unity but  connection.ControlPointsList.  doesnt have a extenstion method for name.

ie What I'd like to do is   

Code:
return connection.ControlPointsList.name
or 
Code:
connection.ControlPointsList.tag


Sorry for all the questions but I'm finding it quite difficult to get to grips with the api.
Reply
#7
No worries for the questions:

Splines (class name CurvySpline) and control points (class name CurvySplineSegment) are all inheriting from MonoBehaviour, so as any MonoBehavioue, you can call the gameobject property on them to get the GameObject the MonoBehaviour is attached to.
ControlPointsList is a list of control points. So if you retrieve a control point from the list, let's say ControlPointsList[0], you can then call gameObject.name to get it's name.
And keep in mind that CurvySplineSegment has a Spline property to get the spline it is part of.
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
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
Thumbs Up Can't delete connection lacota 3 6 03-16-2024, 11:34 AM
Last Post: _Aka_
Question How to attach custom components to output Sacryn 3 6 02-23-2024, 09:42 AM
Last Post: _Aka_
  Add noise to spline controller movement DekoGames 2 10 02-06-2024, 01:28 PM
Last Post: DekoGames

Forum Jump: