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
  Skip Input Mesh if spline has too much bend Zilk1 1 2 1 hour ago
Last Post: _Aka_
  animating points on a spline Antonio 11 18 09-17-2023, 09:55 AM
Last Post: _Aka_
  Spline.Length not updated unless I add a point to spline (or modify it) first. _RicO 3 6 08-26-2023, 08:41 AM
Last Post: _Aka_
  Raise spline events during edit mode arcadeperfect 3 6 08-24-2023, 08:38 AM
Last Post: _Aka_

Forum Jump: