Simple Status UI (scale the distance)

Hi! I’m having trouble to implement something like the image attached.
Basically, I want the progress of the snail away from the flag to be displayed on my HUD.
(take a look at the game window of the editor, upper center)

I’m guessing I just need to scale the distance from the moving object to the flag but I have no idea how. Please help!

Thanks!

Then yeah, scale the distance. It’s really simple.

Pseudo code in C#:

transform.position.x = (float)(currentDistance / wholeDistance * uiDistance);

This code will be attached to the small snail progress icon. transform.position.x is the snail progress icon’s x value. currentDistance is the current distance the player has already got. wholeDistance is the entire distance the player has to finish. uiDistance is the distance between the snail progress icon and the yellow icon thing.