public LinearPath(ArrayList<Destination> destinations) { this.destinations = destinations; // Make sure all times are set correctly Vector2 temp = new Vector2(); int index = 0; int lastIndex = destinations.size() - 1; for (Destination dest : destinations) { if (index < lastIndex) { Destination next = destinations.get(index + 1); dest.moveTime = temp.set(next).sub(dest).len() / dest.speed; } dest.startTime = totalTime; totalTime += dest.moveTime; index++; } }