UE4 Snap Character to Spline Component

Hi, any help would be greatly appreciated.

I was wondering how I would, given a world location of the character the moment he hits the collision box of the spline mesh, map that to a parameter that would be used to do some lerp along the spline, such that his movement is constrained to be within that spline.

In the screenshot below, I found this Spline-specific function: “Find Location Closest To World Location”. Okay that’s nice, but now I need to map that to a variable that can be used with other Spline-specific functions such as “Get Location at Distance along Spline”. Is there a way to do that efficiently?

I found a less than optimal solution by brute forcing 100 samples along the interpolation’s domain to see which of them output a World Location that will give the least difference when compared to the World Location given by “Find Location Closest To World Location”. Hoping to see if there are any better ways to go about this?