Unity-Pathfinding
Unity-Pathfinding copied to clipboard
If Pathfinder.FindPath argument `associatedObject` is null, path finding does not ignore invalid nodes.
If no argument for associatedObject is provided, or its null, then this check fails to check for invalid nodes, causing the path to use invalid nodes. It may also be possible to fail if neighbor.associatedObject is null, but I am not sure if that can happen.
//The associated object check is so the enemy ignores pathing through it's own bad sector
if ((!neighbor.valid && neighbor.associatedObject != obj) || closedSet.Contains(neighbor))
{
continue;
}
Instead, I think it should be:
//The associated object check is so the enemy ignores pathing through it's own bad sector
if ((!neighbor.valid && (obj == null || neighbor.associatedObject != obj)) || closedSet.Contains(neighbor))
{
continue;
}