Is it possible to somehow break the path into visible segments?

Hello everyone.
28

How to make a mechanic that is shown in the picture? When you hold down a button, for example, “Alt” and press the mouse button, points are formed along which the character must pass.
Up to this point, I’ve only worked with one path. Here is the approximate logic of my script.

LineRenderer lin;
    public float dist;
    List<Vector3> buffer = new List<Vector3>();
    AILerp ai;
    RaycastHit hit;

    private void Update()
    {
        if (ai.remainingDistance <= dist)
        {
                       
                ai.destination = hit.point;
                ai.SearchPath();
                ai.GetRemainingPath(buffer, out bool stale);
                lin.positionCount = buffer.Count;
                lin.SetPositions(buffer.ToArray());
         }
        if ( Input.GetMouseButtonDown(0))
        {
            ai.canMove=true;
        }
    }

What must I do next?