#Help interpreting what I'm seeing in the Watch window of the debugger...

1 messages · Page 1 of 1 (latest)

glad dagger
#

Making a maze game and I need each cell to know if it's got neighbors N/S/E/W. I've had another script run through the permutations and assign the Cell class as appropriate.

#

This cell is at the eastern edge of the map, so neighborEast never had anything assigned to it. So why do the other three say "null" and neighborEast says null??

#

I'm asking because elsewhere I'm testing neighbors for have they been populated and having issues...

#

Here is where I'm checking each cell for valid neighbors on startup...

#
        {

            thisRow = cell.row;
            thisColumn = cell.column;

            cell.neighborNorth = GridAccessor(thisRow + 1, thisColumn);
            cell.neighborSouth = GridAccessor(thisRow - 1, thisColumn);
            cell.neighborWest = GridAccessor(thisRow, thisColumn - 1);
            cell.neighborEast = GridAccessor(thisRow, thisColumn + 1);
        }```
#

And then the GridAccessor method is here:

#
    {
        if (row > rows - 1 || row < 0)
        {
          return null;
        }

        if (column > columns - 1 || column < 0)
        {
            return null;
        }
        Cell cell = grid[row, column];
        return cell;
    }```
stoic zinc
#

Hello! I'm not sure exactly about what is happening, but what appears when you click on the arrow to show some of the "null" object information?

glad dagger
#

I can see the properties of the various cells (a custom class) that are assigned to each location in the grid[,] array.

worldly prism
#

Is there a chance the cell is actually out of bounds? Maybe the code says columns and rows is something, but you changed it within unity?

glad dagger
#

Unlikely at best. I'm iterating through the grid with validated numbers...

#

No, this is really coming down to "why are ALL of these listed as some varation of null?"