How can i draw a blue line in scene window show what way the character already walked ?

int index = 0;
private void WayPoint()
{
if (index == waypoints.Length)
index = 0;
target = waypoints[index].transform;
float distance = Vector3.Distance(myTransform.position, target.transform.position);
Debug.DrawLine(target.transform.position, myTransform.position, Color.red);
Debug.DrawLine(target.transform.position, myTransform.position, Color.blue);
myTransform.rotation = Quaternion.Slerp(myTransform.rotation, Quaternion.LookRotation(target.position - myTransform.position), rotationSpeed * Time.deltaTime);

        //move towards the player
        myTransform.position += myTransform.forward * moveSpeed * Time.deltaTime;
        if (distance < 2f)
            index++;
    }

Now i’m drawing a red line that show the next target(waypoint) the character will go to. But i want to add a blue line that will show what way the character already did from the original start position and all visited waypoints until the real time character position. So when the character will walk between the waypoints it will show two lines red for the next target and blue what was visited already.

This WayPoint() method i call it from the Update() function.

I just added the same line like the Red color with Blue color i just can’t figure out how to draw the line between the current character position and where he visited so far.

Debug.DrawLine(waypoints[index-1].transform.position, myTransform.position, Color.blue);

Do you mean something like this?

Excuse the crude Mspaint :wink:

88562-untitled.png