Thoughts on this lesson (Dictionaries)

I found the use of “coordinates” multiple times while the dictionary was being built a little confusing. Not so much in concept, just in how it reads since “coordinates” is used for the key and a variable on Node. To help differentiate this I tweaked the code a little to show how each use of coordinates is a little different. Hope someone finds it helpful.

    private void CreateGrid()
    {
        for (int x = 0; x < gridSize.x; x++)
        {
            for (int y = 0; y < gridSize.x; y++)
            {
                Vector2Int xyCoords = new Vector2Int(x,y);
                grid.Add(xyCoords, new Node(xyCoords, true));
                Debug.Log(grid[xyCoords].nodeCoordinates + " = " + grid[xyCoords].isWalkable);
            }
        }
    }

Privacy & Terms