0
\$\begingroup\$

I'm not sure if this is considered grid-based, because as you can see there is also a line. And that line is also a non-walkable point, I have no idea how do I create a path-finder with a non-grid-based. Currently I am using pacman-astar grid-based pathfinder, but it won;t fit to my game because I am using a line to block a characters path.

In the image below is the map with lines.

enter image description here

In the image below is the graph, white is walkable, black is not.

enter image description here

In the image below is the actual path-finding, as you can see in the red circle still passing through because I am using gridbased.

enter image description here

\$\endgroup\$
  • \$\begingroup\$ I infer from your diagram that a diagonal is passable when one (both?) of the orthogonal connections are clear - Just add this as a check on top of the check that the diagonal grid point is clear. \$\endgroup\$ – Pieter Geerkens Oct 7 '16 at 16:01
3
\$\begingroup\$

So the problem is that your pathfinding algorithm also just checks if it can move diagonally but it doesn't keep in mind that it's unable to pass diagonal if both the neighbouring blocks are walls.

For example: If you move diagonally right up, it will not check the block above and the block to the right.

Add a check to your algorithm and this should probably fix it. Or you can just disable checking diagonal spaces.

| improve this answer | |
\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.