Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Closest Point on Spline (+Offset) to some World Position

I'm working on a driving action game. I'd been using Curvy to control the cars along the spline, but for several reasons, I switched to PhysX based cars. I finally have them working the way I want on straight roads, but of course I want curvy roads in my game, and I'm using Curvy to do that Smile

For this reason I'm wondering how it might be possible to get the closest point on the road spline to some carTransform.position. My roads are curvy spline based and use a coordinate system of normal Curvy Position + and offset (called Lane Position). The offset is very important to this because for lane tracking of course.

So in the image below, imagine that green car squiggle is a gameobject not controlled by a Curvy controller. However I want to know its current "Road Position"
Assuming a Lane width of 3 (so range of -6 to 6 of Lane position) that car would be at SplinePosition "P" and LanePosition 1.5f. (just eyeballing it)

How can I find this out programatically given the car's transform position?

[Image: QB7VYkx.png]

If I can figure this out, I'll get a major breakthrough in being able to use curved roads with my PhysX based cars Smile

Messages In This Thread
Closest Point on Spline (+Offset) to some World Position - by nomadigi - 01-23-2018, 06:36 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  player stuck on spline Dextex 4 66 07-17-2021, 04:52 PM
Last Post: _Aka_
  Locking the UV's of a closed spline John_MLS 1 105 07-09-2021, 03:54 PM
Last Post: _Aka_
  Accessing generator's input spline in script, changing it at runtime smackledorf 3 277 06-17-2021, 01:59 PM
Last Post: _Aka_
  Questions about Generator: mesh/objects within spline, snap to control point dartboard 5 442 06-09-2021, 12:42 PM
Last Post: _Aka_

Forum Jump: