Connecting objects in a list with a line that updates as you change their position
Hi,
I'm trying to connect a list of objects to create a path so that if I move one of them in the Editor it will update the line connecting to it. For example, if I have 4 objects in a List, connected by a line (object 1 connected to 2, 2 to 3 and 3 to 4 - but not 4 back to 1) and I drag object 3, the line connecting it to object 2 and 4 would update as I do so.
Can anyone help me out with how to construct this code in this way? I'm guessing this has to be done in OnDrawGizmos, or inside Update as a LineRenderer?
Any help would be great - thanks in advance.
public Transform[] myList;
void Draw()
{
for (int i = 1; i < myList.Lenght; i++)
{
Debug.DrawLine(myList[i-1].position, myList[i].position, Color.red);
}
}
I didn't tried the code but algoritm could be like that in my opinion.
Your answer
Follow this Question
Related Questions
issue with LineRender start from 0 0 Answers
How can i decrease linerenderer positions 0 Answers
line render some lines not visible 2 Answers