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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  How to generate gameobject on the control point Yang Yi 0 1 Yesterday, 11:43 AM
Last Post: Yang Yi
  Method of scattering objects along spline joebain 1 3 11-26-2024, 03:20 PM
Last Post: _Aka_
  Curvy Line Renderer for UI Spline? gekido 5 13 10-29-2024, 10:19 AM
Last Post: _Aka_
  Nested Spline Volume Spot Instantiation merobbins5 3 7 07-26-2024, 09:58 AM
Last Post: _Aka_

Forum Jump: