Simple mapping to indicate car position on the road

This is a simple 2d Car racing and looking far a simple solution. How can I indicate the car position on the road?
Please check the image for better understanding… 77579-car-minimap.jpg

There are two methods that come to mind for your current problem.

Option 1:

The first is marking a beginning position and an ending position with transforms. Then whenever the car moves update a UI slider with the progress of the car movement between the beginning and ending transform positions. So your UI slider would look something along the lines of:

public void UpdateCarPosition(Transform carPosition)
    uiSlider.value = (startingPositionTransform.x + carPosition.x) / endingPositionTransform.x;

Set the uiSlider minValue to 0, and maxValue to 1, and it will act as a percent completed.

Option 2:

You can create a second camera that will render a different layer. You can place a white box on a seperate rendering layer at the car position and the flat line on the same layer. Disable this rendering layer from the primary camera and enable only that layer on the second camera. The camera will be placed so that its view is how you want it, and then don’t move it. Set the camera clear flags to “Don’t Clear”, and then it will only render that white box and blue box, and then the primary camera will render the game normally behind it. May also need to set the depth of the cameras.

The first option requires a little more setup. The second option is probably the easier of the two methods for setup, but requires a little more know-how about the Unity engine and how it renders scenes. What’s easier is up to you; and also what may fit your situation better is dependant on what you’re trying to achieve. But either method should work.