hi there im trying to generate a floor for my level in a checkered pattern that is expandable by setting the columns and rows that are needed but its not turning out right here is the code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class floor : MonoBehaviour
{
public GameObject greytile;
public GameObject blacktile;
public int colunms;
public int rows;
public Transform floorholder;
private List<Vector3> gridpos = new List<Vector3> ();
void Start ()
{
initializelist ();
makefloor ();
}
void initializelist ()
{
gridpos.Clear ();
for (int z = 0; z < colunms; z++) {
for (int x = 0; x < rows; x++) {
gridpos.Add (new Vector3 (x, 0, z));
}
}
}
void makefloor ()
{
for (int z = 0; z < colunms; z++) {
for (int x = 0; x < rows; x++) {
if (x % 2 == 0) {
GameObject GT_Clone = Instantiate (greytile,new Vector3(x,0,z) , Quaternion.identity)as GameObject ;
GT_Clone.transform.SetParent(floorholder);
} else {
GameObject BT_Clone = Instantiate (blacktile,new Vector3(z,0,x), Quaternion.identity)as GameObject ;
BT_Clone.transform.SetParent(floorholder);
}
}
}
}
}
could someone please tell what im doing wrong and what to change,thank you in advance, P.s im am aware that columns is spelled wrong in the code i will fix that p.p.s i also know about the dot in the first part of makefloor and it hase been changed on my end
this is what it looks like after the changes