Im trying to make a cube world and i am trying to check if the block above the current block is =0 or =1 but the if statement isnt working. Even if the block above is 1 it is still returning as if it is 0. I dont know what is wrong. Any suggestions on what i did wrong? Thanks
using UnityEngine;
using System.Collections;
public class DataScript : MonoBehaviour
{
public byte[ , , ] data;
public int worldX = 10, worldY = 10, worldZ = 10;
public GameObject block;
void Start ()
{
data = new byte[worldX, worldY, worldZ];
for (int x=0; x<worldX; x++)
{
for (int y=0; y<worldY; y++)
{
for (int z=0; z<worldZ; z++)
{
if (y<2)
{
data[x, y, z] = 1;
}else{
data[x, y, z] = 0;
}
if (data[x, y, z] == 1)
{
GameObject cube = Instantiate(block, new Vector3(x, y, z), Quaternion.identity) as GameObject;
}
if (y+1 < worldY)
{
if (data[x, y, z] != 0)
{
if (data[x, y+1, z] == 0) // This is the line that isnt working
{
print("Nothing Above");
}
}
}
}
}
}
}
}