i know what my issue is but I’ve no idea how to fix it. I have an Game Object with 50 Spawn Points as children, is there a way of using a for loop to assign each of the spawn points to an array. The spawn points were created inside unity and not via scripts. i have it like this as i would like to use the game objects position in the world to spawn a light bulb in its place. Between 10-15 light bulbs will be spawned in the game, which is my reasoning for having 50 possible locations to put the light bulbs.
public class LightBulbSpawn : MonoBehaviour {
public GameObject lightBulb;
public GameObject[] spawnPoints;
private int NumOfBulbs;
// Use this for initialization
void Start () {
PickPositions ();
}
void PickPositions(){
spawnPoints = new GameObject[50];
NumOfBulbs = Random.Range (10, 15);
GameObject tiornan;
for (int i = 0; i <= NumOfBulbs; i++) {
for (int x = 0; x < NumOfBulbs; x++) {
int temp = Random.Range (0, 49);
tiornan = Instantiate (lightBulb, spawnPoints [temp].transform.position, Quaternion.identity)as GameObject;
}
}
}