Problem moving diagonally through adjacent walls with mp_grid

D

DirectOrder

Guest
I am using the mp_grid functions to generate pathfinding for my enemies, and I do have "allow diagonal" set to true, however, if two walls are diagonal from each other, the enemy does not see that as a valid path. For instance:

a = enemy
b = goal
X = wall

--------------------
--------X-----------
--------X-----------
--------X---b-------
-----a---X----------
---------X----------
---------X----------
--------------------

The enemy should be able to move forward 3 spaces, then up-right diagonally through the break in the wall, but the way mp_grid calculates paths, it doesn't allow for diagonal movement like this. I understand why it doesn't allow it. But I need to find a workaround. Has anybody figured out a way to make it see this as a valid path?

I know I could code my own pathfinding algorithm, and I did (A*), but it is way too slow. The built-in pathfinding seems to run muuuuch faster, so I'd really like to figure out a way to use it. I just need it to see two diagonally adjacent empty cells as a valid path somehow.
 
Last edited by a moderator:

Evanski

Raccoon Lord
Forum Staff
Moderator
Because there is not a vaild cell between the adjacent points in the wall so it sees it as a connected wall and will go around it, mp grids are grid based thus there must be a line of cells all connected from point A to B to path find
 

NightFrost

Member
That's how A* built into mp_grid treats diagonal links, and there's no way to adjust it. Unfortunately custom pathfinding is your only alternative.
 
K

KiD_Rager

Guest
I have the same issue. It's significantly worse when the object moving with mp_grid has a sprite larger than the wall itself.

Several threads cover this and have some solutions, nothing concrete though until you see what works best for you:



You could also look into the Dynamic MP Grids post that @Nocturne wrote. Very good reference and may solve your problem the best.


Good luck!
 
D

DirectOrder

Guest
Thank you all for the info! I decided to scrap pathfinding altogether. I really wish the built-in pathfinding was more configurable, or I wish I could figure out why the built-in A* implementation is 100x faster than mine lol

Oh well. Thanks again!
 
Last edited by a moderator:
Top