Hey,
I have a problem that when the GridNode from which we start navigation is Unwalkable the path node is picked incorrectly.
Let’s have a look at the gif below. By design only 1 creature can be per GridNode, so when it is there I mark the node Walkable = false
. But then when I navigate from Minotaur to Demon it always picks the top node as the first one. Why is the top cell first? Shouldn’t the first node be picked the one the closest to the target?
And the Grid looks like this
The code looks like this:
private void findPath()
{
var myPosition = ParentCell.transform.position;
var playerPosition = MyGrid.Instance.player.ParentCell.transform.position;
var queryPath = ABPath.Construct(myPosition, playerPosition);
_seeker.StartPath(queryPath, delegate(Path path)
{
if (path.error)
{
throw new NotReached();
}
if (path.path != null)
{
_currentNavigationPath = path;
_currentNavigationIndex = 0;
}
});
}
What am I doing wrong?