Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Getting object on spline Position when Spline has coordinates larger than 2000
#1
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.
Reply
#2
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#3
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 Wink
Reply
#4
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.
Reply
#5
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 will help a lot keeping Curvy relevant in the eyes of the Asset Store algorithm.
Reply
#6
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Curvy Line Renderer for UI Spline? gekido 3 6 04-04-2024, 12:56 PM
Last Post: _Aka_
  Get position of all control points for a spline gekido 1 6 03-28-2024, 10:08 PM
Last Post: _Aka_
Bug Changing spline connection in inspector causes splines to revert to defaults lacota 3 6 03-18-2024, 07:55 PM
Last Post: _Aka_
  GO can't fit end of the spline GameDeveloperek4123 3 14 03-04-2024, 11:06 AM
Last Post: _Aka_

Forum Jump: