Distance along an axis?

Hello,

I’m trying to get the distance along an axis, but can’t figure it out.

For example, if my player (blue star) is approaching a finish line (the red dot being it’s pivot point), how can I get the distance from that line, along it’s proper axis?

The player can be in the center of the road, off to the side, or a million miles in the sky. All that matters is far away he is from that point, along it’s facing axis.

Any ideas?
Thanks!

Edit: Changed the picture/desc to make it more clear.

FVector Diff = EndPoint - StartPoint;
Diff.Normalize();
float Dist = FVector::DotProduct(Diff, (EndPoint - PlayerPosition));

Is this homework? It looks like homework. Look at dot products.

It’s not homework lol.

Trying to figure out the distance the player is between 2 points. Sort of like a how far the player is between a start and finish line, where only the distance from the start/finish line matters, and not his actual position on the road. Can’t seem to get anything working properly.

I’ve never been able to fully wrap my head around dot product.
That was exactly what I needed, thankyou!