Okay, so what I want to do is create a Tile everywhere there is an “X”.
so what I think i would do is:
var SectionOne: "XXXXXXXXXXXXXXXXXXX";
var SectionTwo: "XOOOOOOOOOOOOOOOXXX";
var SectionThree: "XOXXXXXXXXXXXXXOXXX";
var SectionFour: "XXXXXXXXXXXXXXXOXXX";
var SectionFive: "XOOOOOOOOOOOOOOOXXX";
var SectionSix: "XXXXXXXXXXXXXXXXXXX";
So I would instantiate a gameobject for every X but for “O” I would instantiate a wall…
How do you do this?
How about this- instead of using a string like that, why don't you use an array of booleans? (actually integers, since they're smaller...)
int[,] tiles = new int[,]{
{0,1,1,1,1},
{0,1,1,1,1},
{0,1,1,1,1}
};
Then, to instantiate objects over a space, do something like this-
for(int i; i < tiles.GetLength(0); ++i)
{
for(int j; j < tiles.GetLength(1); ++j)
{
if(tileSegments[i,j] != 0)
{
Instantiate(obj, new Vector3(i * tileWidth, 0, j * tileHeight), Quaternion.identity);
}
}
}
Please note that you can't assign these in the editor, or keep them serialised along with your other properties. You either have to hardcode them, or use a special custom editor.