it report error of this line: “floors[x,y] =(GameObject)Instantiate(floors, Vector3 (forX, 0, forZ), Quaternion.identity);” and the error is:
" error CS0119: Expression denotes a type', where a variable’, value' or method group’ was expected"
I wonder if someone know why that happened.
Thanks!
It may help if you pointed out what line that error was talking about.
Though I suspect it could be Vector3 needs to be new Vector3 if you are using C#.
Edit:
I assume you meant to have a floor prefab such as
public GameObject floor; //Assign prefab here
public GameObject[,] floors; // This is the 2D array being generated
void Start()
{
floors = new GameObject[20,20]; // Initialising the array of 20 * 20 gameobjects
float forX=-200f;
float forZ=-200f;
for (int x = 0; x < 20; x++)
{
for (int y = 0; y < 20; y++)
{
// Creating the game objects within the array at the specified indexes
floors[x,y] =(GameObject)Instantiate(floors, new Vector3 (forX, 0, forZ), Quaternion.identity);
forX+= 20f;
}
forZ+= 20f;
}
}
You have to assign the prefab to floor and not floors