private void findRandomPedestrian()
{
GameObject[] pedestrians = GameObject.FindGameObjectsWithTag ("pedestrian");
if (pedestrians.Length == 0) {
Debug.LogError ("No game objects are tagged with pedestrian");
} else {
System.Random random = new System.Random ();
int position = random.Next (1, pedestrians.Length);
bool isPedActive = pedestrians [position].GetComponentInChildren<Pedestrian> ().isActive ();
while (!isPedActive) {
position = random.Next (1, pedestrians.Length);
isPedActive = pedestrians [position].GetComponentInChildren<Pedestrian> ().isActive ();
//Debug.Log ("Set new pedestrian to follow : " + currentPedestrian + ". Is active : " + isPedActive);
}
currentPedestrian = pedestrians [position];
//Debug.Log ("Set new pedestrian to follow : " + currentPedestrian + ". Is active : " + isPedActive);
}
}