// New direction will be something completely random! private void NewDirection() { // Ensure waypoints are within bounds of number of waypoints if (curDestination < waypoints.Length - 1) { // Determine if waypoints need to be sequential or random if (globalBehavior.getSequentialStatus()) { curDestination += 1; } else { int randomNum; // Holds random number do { // Selects a random waypoint randomNum = Random.Range(0, waypoints.Length); } while (randomNum == curDestination); // Make sure we select a new location // Assign random destination curDestination = randomNum; } } else { // Default to first waypoint curDestination = 0; } }