I can't figure out why it's telling me the object is null when I'm trying to fill the array with an object that I'm constructing.
public int size;
// Use this for initialization
public void Start()
{
size = 10;
Unit[,] array = new Unit[size,size];
int i, j;
for(i = 1; i<=size; i++)
{
for(j=0;j<size;j++)
{
if(i>=1&&j>=1)
{
array[i, j] = new Unit(array[i - 1, j].getHeight(), array[i, j - 1].getHeight());
}
else if(i>=1)
{
array[i, j] = new Unit(array[i - 1, j].getHeight(), 0);
}
else
{
array[i, j] = new Unit(0, 0);
}
}
}
for (i = 0; i <= size; i++)
{
for (j = 0; j <= size; j++)
{
Debug.Log(array[i,j].getHeight());
}
}
}
the Objects I am creating come from a constructor; Unit(int,int) It says line 23. I'm assuming that it means that the object doesn't exist in the the array but i'm creating the object so IDK