Yonaba / Jumper

Fast, lightweight and easy-to-use pathfinding library for grid-based games
http://yonaba.github.io/Jumper
MIT License
619 stars 125 forks source link

(dis)allow corner crossing in diagonal mode #30

Open Yonaba opened 10 years ago

Yonaba commented 10 years ago

When diagonal moves are allowed, an agent when turning around a corner (wall edge) can cross the corner. This behaviour might not be suitable for some games, as it results in unaesthetic paths, especially for agents having a certain size. Although it can be solved with clearance, we shoud be able to allow/disallow the ability to cross a corner when making a diagonal move.

This can be easily implemented by skipping an adjacent neighbor when getting the list of a node neighbors. Assuming dx and dy are the normalized vectors of movement, we check if the node at (currentNode.x+dx, currentNode.y) is walkable. In case it is, we only add it to the list of neighbors if cornerCrossing is allowed.

The ability to (dis)allowCornerCrossing will be added as a new method to the pathfinder interface.

Abdo023 commented 6 years ago

Hello, was this feature added? I can't find it in the pathfinder.lua script, also "myFinder:setTunnelling(false)" doesn't work. Have you abandoned this project? or am I missing something? I'm not very good at algorithms and I don't fully understand this framework, I'm unable to add it myself.