I am trying to check if there is an object to any side of it in the 3d array. My function to check is :
void UpdateSides ()
{
Vector3 myPos = transform.position;
int x = (int) myPos.x;
int y = (int) myPos.y;
int z = (int) myPos.z;
if (levelData[x, y, z] != null)
{
if ( x < levelData.GetLength(0) && y < levelData.GetLength(1) && z < levelData.GetLength(2))
{
print ("Pass GetLength Test");
if (x-1>-1 && y-1>-1 && z-1>-1)
{
print ("Pass Over 0");
if (levelData[x, y+1, z] == null)
{
print ("Nothing Above");
}
if (levelData[x, y+1, z] != null)
{
print ("Something Above");
}
if (levelData[x, y-1, z] == null)
{
print ("Nothing Below");
}
if (levelData[x, y-1, z] != null)
{
print ("Something Below");
}
if (levelData[x+1, y, z] == null)
{
print ("Nothing Right");
}
if (levelData[x+1, y, z] != null)
{
print ("Something Right");
}
if (levelData[x-1, y, z] == null)
{
print ("Nothing Left");
}
if (levelData[x-1, y, z] != null)
{
print ("Something Left");
}
if (levelData[x, y, z+1] == null)
{
print ("Nothing Forward");
}
if (levelData[x, y, z+1] != null)
{
print ("Something Forward");
}
if (levelData[x, y, z-1] == null)
{
print ("Nothing Back");
}
if (levelData[x, y, z-1] != null)
{
print ("Something Back");
}
}
}
}
}
I have been trying to figure out what i am doing wrong and i just cant seem to find it. Im trying everything. Im using one of the lines that was recommended and now it still isnt working.