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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
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 helps immensely. Thank you.
Available for freelance work—feel free to reach out.
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
  Morph game object along curve. mikechr2000 5 124 02-04-2025, 09:30 PM
Last Post: _Aka_
  Disable a spline's gizmo when not selected or disabled. mikechr2000 1 52 02-03-2025, 09:34 AM
Last Post: _Aka_
Information Questions regarding spline colliders and collisions with rigidbodies Spyboticer 7 285 01-20-2025, 12:25 PM
Last Post: _Aka_
  Extrude mesh along spline. New and confused user GhostStalker 3 86 01-02-2025, 09:58 AM
Last Post: _Aka_

Forum Jump: