node null reference

So like most on here I am very new to coding and am still wrapping my head around some of the ins and outs of c#. I am attempting my first crack at my own game. I am using some code from a tutorial to make the grid and path-finding and node system, with my own tweaks added in for my purpose. Everything works up until now. I have a working grid that my player can travel on. I have made each node a large 10x10 area space and am using each node as a static room. I am trying to write a script to spawn a room in the next node as the player gets to a collider i set at edge of the node. I have a door that opens from the same collider so I know its working.

The call to the path finder code works cause its getting called to make my player move from node to node. I keep getting a null reference error when I try to use the node of object. The debugging is me making sure that the curRoomNode has a value right before I call the GetNeighbours() method.

I am using this code so far…

void SpawnRandomRoom()
    //spawns item in array position between 0 and number of rooms in list
    int whichRoom = Random.Range(0, listOfRooms.Count);

    GameObject myObj = Instantiate(listOfRooms[whichRoom]) as GameObject;


    // Find current node that room is on and get neighbours
    Vector3 curRoomWorldPos = transform.position;
    Debug.Log("world pos " + curRoomWorldPos.x+", "+ curRoomWorldPos.y+", "+curRoomWorldPos.z);

    Node curRoomNode = GridBase.singleton.GetNode((int)curRoomWorldPos.x,(int)curRoomWorldPos.y,(int)curRoomWorldPos.z);
    Debug.Log("Current node is:" + curRoomNode.x + "," + curRoomNode.y + "," + curRoomNode.z);

    List<Node> curNeighbours = new List<Node>();

    foreach (Node neighbour in pathfinder.GetNeighbours(curRoomNode))
    Debug.Log("The neighbours are: " + curNeighbours);

    if( == "Door West")
        //myObj.transform.position = 
    //myObj.transform.position = transform.position;

In the froeach part It calls to get neighbour nodes. but it keeps giving me the nullreferenceexception error. I have tried a few other ways to call the node to get the neoighbours and all keep giving me the same error. Am I using the curRoomNode variable wrong?

I’d say your pathfinder can’t find any neighbours. Can you post the GetNeighbours method? OR at least check what values your node properties have in the debugger?