Function "Get a Distance at Location Along Spline"

I want to move an object at constant speed through a spline. I have seen that we have the function “Get Location at Distance Along Spline”, how could I do the reverse? “Get Distance at Location Along Spline”?

Combinating both functions it would be extremly easy to move objects through a spline at constant speed.

Thank you.

EDIT:
I also need it to order to an object “move to that point”. We have a function to obtain the closest to world location, but still it is just a vector, not the distance from the starting point, so I lack of a way to know where this point is in the spline.

You can move them at a constant speed by having the distance moved be directly proportional to the delta time. So have a variable “distance” and one for “elapsed time”. Each increment of time (delta time) adds to the “distance” this distance is then converted to a location on the spline. For example, if you say move 5 units per second, each second elapsed adds 5 to the “distance variable”. At time 0 distance is = elapsed time (0) * 5 units per second “speed” = 0. At time 1 second distance = elapsed time (1) * 5 units per second = 5 units. Time 2 would give you 10, 3 would be 15 and so on. So you really only need the “get location at distance along spline” function. Here is an example of what I am talking about.

If you mean you want constant speed independent of frame rate then you simply need to multiply your incremented distance value (5 units) by delta time from tick or timeline etc.

Thank you, but this only works if you know the distance of the point, which is exactly what I need.

I want to order to the object “go to the closest point to a location”. I can obtain the point in the spline, but how can I know if this point is behind or in front of the object?

I’ve found the solution here:
https://forums.unrealengine.com/unreal-engine/feedback-for-epic/97850-get-distance-at-location-along-spline

1 Like

There are a bunch of functions for splines. One of them should work for you. Look at just these that I found with a quick search from the spline component type in “spline” into the search box and tons and tons of things come up.

I don’t quite understand your mechanic to be honest. You have objects and spline points and some actor you want to move to the object, but the initial question had nothing to do with any of that you asked about moving something at constant speed along a spline. You are very confusing my friend. Please explain yourself better. Are these objects part of the spline? Are you using the spline as a navigational tool for some AI? What does it matter if an object is before or after a spline point? Are you trying to figure out how to move backwards on a spline too?

You are confused because you want ot be confused.

My question was clear, I want a “Get a Distance at Location Along Spline” function. If you don’t want to accept that it is your problem.

No need to downvote answers, no need to get angry. I was confused because what you’re trying to do sounded confusing. I’m glad you found the answer. You posted a question on a public forum for people to help you. I am the only one who cared to even attempt to understand you and suggest ways to accomplish what you wanted. Please keep your responses respectful and cordial. Thank you.

Hey some time in the ancient past this link has died, do recall anything about this and a potential solution?

1 Like