Get Closest Distance Along Spline at Location

6daf4546090ffe9dbd8fe629ded3d68d.png
The same this two nodes exist, I would want to suggest a Pull request or a feature where we could have a node that given a certain Location, it will return the closest distance along spline.

Bit of a thread necro here - but I also wanted to do the same thing, and solution seemed non-obvious.

Found an example just after this post - linking here Find Distance Along Spline Closest to World Locati posted by anonymous | blueprintUE | PasteBin For Unreal Engine 4 In the hopes someone else gets their answer quicker!

2 Likes

EDIT: I just realized that the post above me already gives you the answer, but here’s my own code in case it helps anyone coming in off google.

Blueprints:

C++:



float inputKey = SplineComponent->FindInputKeyClosestToWorldLocation(YOUR_WORLD_LOCATION);
float distanceAlongSpline = SplineComponent->GetDistanceAlongSplineAtSplineInputKey(inputKey);

Cheers

3 Likes