Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Connection Question
#1
Question 
Hi, so I want to add a spline (which I will call Spline2)  to another spline ( which I will call Spline1) between 2 existing control points, which I have achieved by doing the following :

1. Storing the data for each control point in Spline1 ( including the connection if it has one )
2. Calculating the position on spline1 where spline2 should start.
3. Delete the control points of spline1 ....  Spline.clear()  and Spline.Refresh()
4. Adding the control points back to spline1 using the stored data for each Control point and adding the addition Control point at the appropriate place, with a connection.

The above works fine when  adding spline 2 to spline 1.

Here's where it doesnt go as intended :

If I want to add another spline ( call it spline3 ) to spline1 and therefore another connection ( it might be in a different place to spline 2 so cant just add spline3 to the connection )
When I'm adding the control points back to the spline as in step 4 above.
I try to add spline2/CP0000 to Spline 1 BUT because that Control point already has a connection ( from when I added spline2 to spline 1) it won't add to the connection.
I've tried deleteing the connection & refreshing the spline but it makes no difference.
  Is there somthing else that needs to be "refreshed" or called for this to work.


Code:
static void AddControlPointDataTOSeg ( CurvySplineSegment seg, ControlPoint ControlPoints, int index )
{


seg.AutoHandles = false;
seg.transform.position = ControlPoints.Position;
seg.transform.eulerAngles = ControlPoints.Rotation;
seg.HandleIn = ControlPoints.HandleINLocal;
seg.HandleOut = ControlPoints.HandleOUTLocal;


if (ControlPoints.Connection != null) {
Debug.Log (" A connection should be added for CP " + index + " control points to add = "+ ControlPoints.Connection.Count);
CurvyConnection.Create (seg);

foreach (CurvySplineSegment SegInConnection in ControlPoints.Connection.ControlPointsList) {
Debug.Log (SegInConnection.name + " / " + SegInConnection.transform.parent.name + " should be added to " + index + " " + seg.transform.parent.name);
SegInConnection.Connection.Delete ();
GameObject obj = SegInConnection.transform.transform.parent.gameObject;
Debug.Log (obj.name);
CurvySpline spline = obj.GetComponent<CurvySpline> ();
spline.Refresh ();
seg.Connection.AddControlPoints (SegInConnection);

}



}

}
Reply
#2
Hi
If your CurvySplineSegment has already a connection, avoid creating a new one, and use the existing one by accessing CurvySplineSegment.Connection
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


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_
Lightbulb Junction & Connection Navigation System Design SAMYTHEBIGJUICY 4 13 11-27-2023, 01:04 PM
Last Post: _Aka_
  Connection "next' control point jh092 3 15 11-22-2023, 11:47 AM
Last Post: _Aka_

Forum Jump: