Problem getting distances across splines

I have a problem: when I try to get the distance of an object to a spline, I do the following

Everything’s fine up to this point. The problem arises when the spline goes back and forth very close to the same point.

At that moment, if iwalk in a zigzag pattern, for example, the distance changes from the outward path to the return path. I need a system that gives me the distance to the spline sequentially, without any jumps. When I go, it should give me the closest distance along the outbound route, and when I return, it should give me the closest distance along the return route.

Why not just define the splines based on the nearest? Essentially, use ‘Get All Actors of Class’ on the splines (if they’re actors, or ‘Make Array’ if they’re components or whatever else), ‘For Each Loop’ them, set the one with the smallest distance ‘On Begin Play’ as ‘Nearest Spline’ and the other as “Return Spline’ or something like that. That way, you’ll only address the spline presently set as “Nearest.”

The idea comes from the below tutorial, around the 8:36 mark:

Unreal Engine AI Vehicle Tutorial 1: Spline Path Following