private void initalizeNodes() { for (int x = 0; x < nodes.GetLength(0); x++) { for (int y = 0; y < nodes.GetLength(1); y++) { GameObject nodeObject = (GameObject)GameObject.Instantiate(node, new Vector3(x, y, 0), Quaternion.identity); nodes[x, y] = nodeObject.GetComponent <NodeScript> (); nodes[x, y].setNodeModel(energySystem.addNode(nodes[x, y].initialEnergy)); } } }