DrawLine problem

I use the DrawLine method in a function called GetLocations()

as this

Debug.DrawLine(AllNodesList[i].transform.position, localNodeDirection, Color.red);

this function is called in the Awake() function

the problem is the red lines are drawn once in the game start and then vanish
I need them to stay so I can see them

they only last for a moment

You need to use DrawLine in Update, since the lines are only drawn for one frame.

–Eric

I used it in update but its drawn twice and then nothing

In that case the variables must be changing. You can copy them to other variables that don’t change, so that you can draw the line properly in Update.

–Eric

but it draws a line from one object but the end is far away from the second one

Vector3 localNodeDirection = AllNodesList[2].transform.position - AllNodesList[1].transform.position;
        Debug.DrawLine(AllNodesList[1].transform.position, localNodeDirection, Color.red);
        print("line drawn between " + AllNodesList[1].name + " and " + AllNodesList[2].name);

DrawLine renders the line for one frame only. If you want it to last, you need to repeatedly render it every frame.

–Eric

I know that
it lasts already when I put it in the Update() function
what I say is
the first point of the line is adjusted
the end point is faaaaaaaaaaaaaaaar away from the real location