Posts: 22
Threads: 5
Joined: Jul 2023
09-03-2023, 05:50 PM
(This post was last modified: 09-03-2023, 05:51 PM by velikizlivuk.)
When Spline is located around world vector3.zero this:
curvySpline.GetNearestPointTF(curvySpline.GetNearestPoint(this.gameObject.transform.position, Space.Self))
does return Relative position correctly (slightly larger than 0).
But, if Spline/Generator is located for instance at:
Vector3 (-2000, 50, -100)
it returns 1 despite the fact that it should be closer to 0.
curvySpline.GetNearestPointTF(curvySpline.GetNearestPoint(this.gameObject.transform.position, Space.World)) - this does the same.
Posts: 2,113
Threads: 92
Joined: Jun 2017
This is weird. Can you please send me a reproduction case? Also, what version of Curvy Splines do you use?
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 22
Threads: 5
Joined: Jul 2023
Using CurvySpline 8.7.2 and it is strange. On two separate scenes when spline and object (that attaches to spline on collision) are moved to x:-2000 relative position of contact is 1 and it should be closer to 0. In both cases when Spline and Object are moved closer to 0,0,0 everything works. Let me debug that further, maybe I did something wrong
Posts: 22
Threads: 5
Joined: Jul 2023
09-04-2023, 01:01 PM
(This post was last modified: 09-05-2023, 01:00 PM by velikizlivuk.)
Using
curvySpline.Flip()
after relative object on Spline position is set, results in this kind of behavior.
Also, converting object position to local space and then doing:
float relativePositionToAttach = curvySpline.GetNearestPointTF(curvySpline.GetNearestPoint(generator.transform.InverseTransformPoint(this.gameObject.transform.position), Space.Self));
is the better way
Everything is fine and dandy.
Posts: 2,113
Threads: 92
Joined: Jun 2017
Glad to read that.
I see that, having a point A, you first get B, which is the nearest point to A on the spline, then you get TFB, the TF of B. You can simplify this by directly getting TFA, the TF of A. A and B have the same TF.
Please consider leaving a
review for Curvy, this helps immensely. Thank you.
Available for freelance work—feel free to reach out.
Posts: 22
Threads: 5
Joined: Jul 2023
Yeah, getting relative position depends on direction of spline, so flipping it after that results in getting opposite relative position if I got it right.