Ways of calculating the distance along spline of an overlap event?

I’m trying to use splines to develop a grinding system for my game.

I know that I can get both the world direction and world location at a distance along a spline; what I currently aim to do is to get the world location of an overlap with the spline, move the character to it with an offset (so that he is perched above it), then scale the world direction to an acceptable value and use it to Add Force. In this way, the player will be attached to the spline, and then shoved along it with the direction of the shove updating each tick based on the direction of the spline.

Conceptually this is all fine. The problem is, I need to determine the Distance Along Spline value dynamically based on where the player is in relation to it… and I just have no idea how to go about that. The distance along the spline is just a float value and it appears the only way to calculate it (given in BPs, anyway) is based on a given spline point. There doesn’t seem to be any way to trace to the position along a spline in any other fashion.

Am I missing something or is this a fool’s errand with BPs?

EDIT: I may have come up with a solution that involves adding the location of all of a given spline’s points to an array, then looping through that array and comparing my actor’s location with each of the given locations to determine which point he is closest to. From there I can snap him to that point and, because I know that point, determine the distance along the spline which he now resides.

The problem with this solution is that in order for it to work even a little bit smoothly I would need most of my splines to have an exceedingly large number of points, and I’m worried about the performance hit of comparing the actor’s position to potentially hundreds of points along a spline (not to mention the performance hit of having a bunch of 100+ point splines in my level). Surely there must be an easier way?

You might try to create a simple grid for your world and always update the player’s position relative to the grid. Then, index each of your spline points relative to this grid. So, get player’s current grid position index and grab the spline point at the same index.

I think what you want to do is not trivial if the spline could be any shape(ie. a spiral stairs shape).
But it could be easier if they are relatively straight.(say for skateboard/rollerblade grind)
Spline are defined by the control points and using a weight function to determine where the actual line is between two or more points.
So what you can do is probably using spline just as visual guide, or collision shape?(I don’t know if UE4 have a spline tube that you can overlap with)
And then pass the spline control points to your character, this way you can just calculate spline position and tangent to update your force to drive your player.
(this also allows you to have multiple splines to engage/disengage.)

Also, find closest point on spline

C++ might be better for this type of task though.