public Transform obstacleLocation;
public GameObject obstacles;
int obstacleRandomNumber;
void Awake()
{
obstacleRandomNumber = Random.Range (0, obstacles.Length);
SpawnObstacles ();
}
void SpawnObstacles()
{
foreach (Transform obstacleLoc in obstacleLocation) {
Instantiate (obstacles [obstacleRandomNumber], obstacleLoc.position,
obstacleLoc.rotation);
print ("Obstacle");
}
}
The problem is obstacleRandomNumber uses the same number for all the Transforms in the array. How do I do it so that the random number uses a different number for every Transform in the array?