public List<Vector3> destinations = new List<Vector3>();
public int numberOfDestionations;
public float moveSpeed = 5f;
public bool loop = false;
public bool moveBack = false;
public Text textCounter;
private Coroutine movementCoroutine;
private bool pause = false;
private bool coroutineRunning = false;
private Vector3 startPosition;
private int countDestionations;
private void Start()
{
for (int i = 0; i < numberOfDestionations; i++)
{
destinations.Add(new Vector3(UnityEngine.Random.Range(-300, 25), -1f, 0));//25, -1f, 0);
if(i > 0)
{
Gizmos.DrawLine(destinations[i], destinations[i + 1]);
}
}
I'm trying to use gizmos but getting exception :
ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
On line 33 :
Gizmos.DrawLine(destinations[i], destinations[i + 1]);
I want that while it's creating the vectors draw lines from the current created vector destination and the next one. A line from index 0 to index 1 to index 2 and so on. So when running the game I will see a net of all the lines connected between the vectors destinations.
i = numberOfDestinations - 1
\$\endgroup\$