Out of Memory Error?

When I try to run Unity after adding the complete BuildPath method it takes a while for the game to start (much longer than usual) and then I get an Out of Memory error. the error is occurring on adding the current node. I assume this is an infinite loop of some kind but i don’t know what could be causing it:.


OutOfMemoryErrorCode

Figured it out, i had entered the line “neighbor.connectedTo = currentSearchNode;” outside of the if statement in the second foreach of ExploreNeighbors.