Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert position of a point on a spline to another spline which is connected
#1
I have 2 splines in my game which they are connected to each other.
The Image: https://gyazo.com/d14e4ee6223c6b41038d9894be942117

I put an object in almost start of the right spline. Also this object has 2 property which are called startPosition and endPosition. They are points which has some distance difference on spline from the object.

The problem which I have this object start position is negeative like -5 in Position but position in spline is always positive. So I want to convert this position to the position on another connected spline.
How can I achieve it ? My guess is by using GetNearestPointTF but I don't know how to get the connected spline from current spline and then Vector3 position of startPosition and convert it.
Reply
#2
Hi,

To get the connection from a Control Point use the Connection property: https://api.curvyeditor.com/610/class_fluffy_underware_1_1_curvy_1_1_curvy_spline_segment.html#ad05977a2fd568b7495c7c4f219d77d78

Use CurvySpline.InterpolateByDistance to get the position (Vector3) of a point from it's distance on the spline
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
(02-14-2020, 12:23 AM)_Aka_ Wrote: Hi,

To get the connection from a Control Point use the Connection property: https://api.curvyeditor.com/610/class_fluffy_underware_1_1_curvy_1_1_curvy_spline_segment.html#ad05977a2fd568b7495c7c4f219d77d78

Use CurvySpline.InterpolateByDistance to get the position (Vector3) of a point from it's distance on the spline

I want to find connected spline by the another one.

Is it correct to use this piece of code ?:

Code:
Spline.ControlPointsList[0].Connection.OtherControlPoints(Spline.ControlPointsList[0])[0].Spline

Also you said using CurvySpline.InterpolateByDistance to get the position of the point but what about if it is not in that spline range ?
Reply
#4
As long as the lists you are accessing have at least one element, yes that code is correct

if the value is not in the valid range, clamp it to the valid range (0;SplineLenght)
Please consider leaving a review for Curvy. This will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#5
(02-16-2020, 08:11 PM)_Aka_ Wrote: As long as the lists you are accessing have at least one element, yes that code is correct

if the value is not in the valid range, clamp it to the valid range (0;SplineLenght)

No, I don't think so if you get what I want exactly.
I mean for example I have a object in Absolute Position of 10 then according to this position I have a point in 15 unit of Absolute Position behind this object. So this point has Absolute Position of -5. Now I want to get world position of this point and then convert it to the Absolute position of the other spline which is connected to this spline.
Reply
#6
otherSpline.InterpolateByDistance(otherSpline.Length - 5) should do the work
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 2 7 hours ago
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 13 03-04-2024, 11:06 AM
Last Post: _Aka_
  Avoiding runtime GC allocations on control point position change Ell223 8 18 02-24-2024, 10:43 AM
Last Post: _Aka_
  Keeping a fixed spline length jh092 3 16 02-21-2024, 06:25 AM
Last Post: Primrose44

Forum Jump: