Finding time of given results from (Find Location Closest to World Location) from Splines

Hi! I am using the Spline node that returns the world location of the closest point in a Spline from a World location reference and is awesome

image

But I also need the TIME value (location IN the spline of the results)
I wish this node were something like this:

image

As I need both (the location and its time equivalen int the spline)
I am thinking about making some recursive function that consists
of split time in 100ths (like split 0 to 1 100 times) and compare the
location of that position in the spline with the results of "find location closest to world location, results for example closests is at time 0,3…then split from 0,25 to 0,35 100 times and repeat twice …more iterations, more precision but I am afraid this is
a very expensive function.

Is there are ready to use node already or a best approach you can suggest? :slight_smile:
Thanks!

Best,
Dany

1 Like

Surely only you know you’re going to be something time based with the spline?

If you do that, once you have the distance along the spline at point X, you can calculate what time that point would be reached at.

Hi @ClockworkOcean Thanks for help!

With ‘Find Location CLosest to World location’ I can get a position in the curve (world space) but I can’t get where is that point in the curve ranged 0 to 1 (time).
Imagine the curve is a track circuit, I get the closest point from the car in the curve and I need the % of the track traveled.

1 Like

Ah… thinks…

I don’t know anything about keys, but they seem continuous, and

image

That’s the one, I think…

The Keys are the points that define the spline. with:

Find Location Closest to World Location and…
Find Input key Closest to World location and…
Get Spline Length and…
Get num of segments

I can do some rule of 3 and get the % 0 to 100…thats good
Downside its a % based on Keys and not actual distance in the path.

What I mean is that you can have a spline with 10 points where first 9 are really
close and the 10th is really far and this wont work…will just sort of almost work
with even distributed keys along the path but its the best I have for now so I will take it :slight_smile:

Thanks again!
Dany

I was getting the impression that input keys are continuous. There’s also a ‘get distance along spline at input key’.

Is it no good?

I also see some sort of averaging code here

inputs keys are just the points of the spline when you draw/define it.
that snippet BP code you share looks promising!!
Will try it :slight_smile:

Why is it a float? Does it just return an int, or 2.5 for something between 2 and 3?

( Not tried it ).

I think it just interpolates beween keys…like a lerp or something like that.

Anyway I took the BP from your link and modded to get exactly what I wanted
( a % evenly distributed ).

I also shared in that awesome page (and I bookmarked it!)

here is the link

As usual I give you :star: :star: :star: :star: :star:

Bonus:

this is the progress of it (early Cars AI)

1 Like

Fab :smiley:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.