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_fl...f219d77d78

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_fl...f219d77d78

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
Rainbow Get nearest point to a world object jamesunity 0 6 15 minutes ago
Last Post: jamesunity
  Change Spline Extrusion material at runtime? linkinballzpokemon 0 6 8 hours ago
Last Post: linkinballzpokemon
  Question regarding Spline Generated Path linkinballzpokemon 9 279 07-01-2020, 06:10 PM
Last Post: _Aka_
  Converting spline collider hit point to spline position jh092 7 207 06-26-2020, 09:48 PM
Last Post: _Aka_

Forum Jump: