Hello everybody,
Im trying to generate 9 prefabs inside a grid
so i do this to generate the positions of grid elements:
public GameObject gridSpace;
GameObject[,] boardArray = new GameObject[3, 3];
void GenerateGrid()
{
for (int i = 0; i < boardArray.GetLength(0); i++)
{
for (int j = 0; j < boardArray.GetLength(1); j++)
{
boardArray[i, j] = Instantiate(gridSpace, new Vector3(j * 8, i * 8, 0), Quaternion.identity);
}
}
}
then on Awake:
private Team team;
private List<RiftMonLogic> MonInTeam = new List<RiftMonLogic>();
private void Awake()
{
GenerateGrid();
team = GameObject.FindObjectOfType<Team>();
var i = 0;
MonInTeam = team.MonInTeam;
foreach (GameObject pos in boardArray){
MonInTeamobj = AddCreatureOnGrid(team.MonInTeam.ca, i, pos.transform.position);
i++;
}
}
And my Team class that im still try to set properly:
public class Team : MonoBehaviour
{
public List<RiftMonLogic> MonInTeam = new List<RiftMonLogic>();
public RiftMonLogic GetRiftMon(int index)
{
return MonInTeam[index];
}
private void Awake()
{
}
}
Now, what i get on my scene is just one of the creature sprite, on position (0 0 0) but i want all nine of them on grid position centered relative to my TeamVisual object on scene
i think its caused by Instantiate(gridSpace, new Vector3(j * 8, i * 8, 0), Quaternion.identity);
or maybe some mess on my prefabs??