I’m trying to add all the neighbors to a list that are within a certain number of movements from the starting position but I can’t seem to find out why not all code paths aren’t returning a value:
public List SetNeighbours(Node currentN, ListopenS,int movementP){
foreach (Node neighbour in GetNeighbours(currentN)) {
if (HighlightT.Contains (neighbour)) {
continue;
}
int newMovementCostToNeighbour = currentN.gCost + Astar.GetComponent<PathFinding> ().GetDistance (currentN, neighbour) + neighbour.movementCost;
int _MPL=MP-newMovementCostToNeighbour;
if (newMovementCostToNeighbour <= _MPL) {
neighbour.gCost = newMovementCostToNeighbour;
neighbour.MPU=newMovementCostToNeighbour;
neighbour.MPL=_MPL;
neighbour.parent = currentN;
if (!openS.Contains (neighbour))
openS.Add (neighbour);
return openS;
}
}
}