Hello everybody, sorry for the very noob question,
I am creating a serie of prefabs that i want to randomly spawn as kind of tiles on game background, i am trying to do like alist or array of GameObjects, and I am not able to make it work, also i wish to get suggestions on a more elegant and effective way to do so…
Thanks
[SerializeField]
private GameObject SpaceBkgnd_0;
[SerializeField]
private GameObject SpaceBkgnd_1;
[SerializeField]
private GameObject SpaceBkgnd_2;
[SerializeField]
private GameObject SpaceBkgnd_3;
public GameObject[] EmptyBkgnd = new GameObject[] { SpaceBkgnd_0, SpaceBkgnd_1, SpaceBkgnd_2, SpaceBkgnd_3 };
void Start () {
for (int x = -6; x < 6; x+=2)
{
for (int y = -6; y < 6; y+=2)
{
Instantiate(EmptyBkgnd[Random.Range(0,3)], new Vector3(Mathf.RoundToInt(playerShip.transform.position.x) + x, Mathf.RoundToInt(playerShip.transform.position.y) + y, 0), Quaternion.identity);
}
}
}