Reputation: 11325
In the Start:
StartCoroutine(moveStuff());
Then:
IEnumerator moveStuff()
{
for (int i = 0; i < allLines.Count; i++)
{
while (Vector3.Distance(instancesToMove[i].transform.position, endPos) > 0.1f)
{
counter++;
endPos = allLines[i].GetComponent<EndHolder>().EndVector;
Vector3 startPos = allLines[i].GetComponent<LineRenderer>().GetPosition(0);
Vector3 tempPos = Vector3.Lerp(startPos, endPos, counter / 500f * speed);
allLines[i].GetComponent<LineRenderer>().SetPosition(1, tempPos);
instancesToMove[i].transform.position =
Vector3.MoveTowards(startPos, endPos, counter / 25f * speed);
//move towards destination
yield return null;
}
}
}
On the first iterate using a break point I can see that the first objects from allLines and instancestoMove are moving. But then instead moving the next objects it's just showing all the rest of the objects in the lists like they were already moved.
The rest of objects in the list appears in their end position already. There is no movement of them like the first loop.
allLines and instancesToMove are List type.
Upvotes: 0
Views: 59
Reputation: 11760
Maybe you should reset counter to zero before the while statement. Otherwise counter / 25f * speed is growing without bound and is higher and higher for the subsequent lines.
Upvotes: 1