I have a script in which i have an array made out of some box colliders and i want each time I have the player enter each one in order to be fine, but if the player skips one collider to throw an error and if it gets to the end of the array, to get back to the top of the array. This is the script I am using:
if (System.Array.IndexOf(TrackCheckpoints.checkpoints, transform) == currentCheckpointIndex)
rightCheckpoint = true;
else
rightCheckpoint = false;
if (rightCheckpoint == true)
currentCheckpointIndex++;
if (currentCheckpointIndex > TrackCheckpoints.checkpointTotalNumber)
currentCheckpointIndex = 1;