I have a 2D array called map
which holds the coordinates to my level like this:
float[,] map =
{
{1, 0, 1, 0, 1},
{0, 1, 0, 1, 0},
{1, 0, 1, 0, 1},
{0, 1, 0, 1, 0},
{1, 0, 1, 0, 1}
};
I'm trying to use this to create a cube at each value. In this map, each value in the area holds the height of my cube. So value {0, 0} is equal to 1 and value {2, 3} is equal to 0.
The line that creates my cube is simple enough I think. It creates it based on a Vector3
value.
My question is, how can I create a for loop to set each value in the Vector3
related to the map array?
For example, for value {0, 0}, the Vector3
would be (0, 1, 0).
Feel free to ask questions if you're confused.
Edit: this is what I'm doint at the moment
for (int x = 0; x < 5; x++)
{
mapX[x] = x;
}
for (int z = 0; z < 5; z++)
{
mapZ[z] = z;
}
for (int x = 0; x < 5; x++)
{
for (int z = 0; z < 5; z++)
{
cubes.Add(new Vector3(mapX[x], 0, mapZ[z]), Matrix.Identity, grass);
}
}
The y value is staying a zero because I can't figure this stupid problem out...
Vector3
- what are you trying to represent here? – Andrew Russell Jun 12 '13 at 7:49Vector3
. So thisVector3
has to be the position of the cube, not its dimensions. In other words, if you want a cube with an height of zero ("each value in the area holds the height of my cube", and you have zeros in your map), this means your cube is just a point, as its width and depth will also be zero. So did you mean parallelepiped? – Laurent Couvidou Jun 13 '13 at 9:44cubes
object? What does itsAdd
method do? – Laurent Couvidou Jun 13 '13 at 9:44