So i had an issue with my pathfinder script was executing before it even got to my Tile script. This cause the Pathfinder to just go where ever it wanted as the isWalkable flag was never set. After a lot of debugging I found that the BreadthSearch executed before the tile script changed the flag.
I was racking my head trying to find an answer. Moving blocks of code to Awake vs Start in Tile, (which broke things since Grid Manager needed to execute first because it never created the grid first.)
Below is part of my Tile script at the Awake function. I removed anything in the start function.
Tile.cs Awake code.
void Awake()
{
gridManager = FindObjectOfType();
if (gridManager != null)
{
coordinates = gridManager.GetCoordinatesFromPosition(transform.position);
if (!isPlaceable)
{
gridManager.BlockNode(coordinates);
/*if (grid.ContainsKey(coordinates))
{
Debug.Log($"Blocking node, tilecs {grid[coordinates].isWalkable} at {coordinates}");
}*/
}
}
}
I then went into Script Execution order ( edit → project settings → Script execution order) and at the bottom added, the Grid Manager followed by the Tile script.
This was from constant debugging and trying to find out what executed first. Nothing else changed except that awake method. (this is from after the blocking nodes video, so any future code changes in that course are not in this code.)