PathFinding.js icon indicating copy to clipboard operation
PathFinding.js copied to clipboard

New diagonal movement option: only to squeeze between diagonal obstacles.

Open rsanine opened this issue 10 years ago • 6 comments

I've made this modification in my local copy to mimic movement in Tibia: Using this option, the pathfinder only routes diagonally when it has to "squeeze between" two diagonal objects (two trees/bushes), otherwise it sticks to N/E/S/W paths.

rsanine avatar Apr 09 '15 02:04 rsanine

It seems like #63 is trying to achieve this - the way to do it is to allow the diagonal routing only when it is blocked by two diagonal obstacles (both obstacles, not "just one", or "none")

rsanine avatar Apr 09 '15 02:04 rsanine

Is it change really useful? I mean why move diagonally when there are exactly two obstacles? If a character can move diagonally despite there being two obstacles, what stops it when there are less?

imor avatar Apr 09 '15 17:04 imor

It is useful when you want the pathfinder to only use diagonal when it is necessary. Otherwise (turning corners or when no obstacles) it should stick to horizontal/vertical motion. Diagonal is only checked so that it does not get "stuck".

If youve ever played Tibia, thats how monsters follow you. They won't take diagonals unless necessary. Some games it looks silly when creatures move diagonally too much.

The change is very tiny - and it seems like others are looking for this feature too.

On Apr 9, 2015 1:39 PM, "Raminder Singh" [email protected] wrote:

Is it change really useful? I mean why move diagonally when there are exactly two obstacles? If a character can move diagonally despite there being two obstacles, what stops it when there are less?

— Reply to this email directly or view it on GitHub https://github.com/qiao/PathFinding.js/pull/96#issuecomment-91303965.

rsanine avatar Apr 09 '15 17:04 rsanine

The other way to achieve this is to set diagonals to 'always', and to increase the costs of diagonals. Is there any way to change the cost of diagonals or tiles types in general?

rsanine avatar Apr 10 '15 15:04 rsanine

I'm not really sure. Lets open this to voting. How many of you think this should be included?

imor avatar Apr 15 '15 10:04 imor

This is the effect:

image

rsanine avatar Apr 24 '15 16:04 rsanine