• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM [SOLVED] Pathfinding Made Less Robotic

B

Bastendorf

Guest
Sorry to be a bother again, but this is the other one I've gotten stuck on. And I'm sorry if this was already asked, but I just don't have the energy or ADD suppression to scan through 133 results related to the keyword "pathfinding".

I'm making an isometric game. Legend of Zelda (the original) being the closest example I could think of off the top of my head. For it, I need for enemies to chase the player. I've already gotten this to work, but it looks harsh and unnatural the way they move. They tend to zigzag noticeably while giving chase at certain angles, and they usually don't walk straight towards me.


The method pictured on the left is fine for tight spaces, but not so much for open spaces like my game would have.
I'm already aware of the method that has an object follow the path and the enemy follow the object with a slower speed, but I feel like that would be a little on the slow, resource heavy side, especially with potentially many enemies chasing the player.

I'm using mp_grid_create and path_start, currently. My hope is that there's a way to get it to recalculate the path after it has determined the grid spaces are open, so that the route taken is more efficient and natural looking. Or at the very least, I'd settle for taking mostly straight lines, line the ones above, and moving towards every second or third point. (It could only be straight lines that did this, though, because it would still have to get the enemy around corners.)

Maybe the solution to this is obvious and I'm just a moron (which I am), but I couldn't figure one out, and I couldn't find any tutorials on it. (Probably because it's not possible. Ya pessimism!)

Any help is appreciated.
 
J

Jaqueta

Guest
Lorenzo Proietti's Optimized Path asset does that!

Basically what it does, is check weather there's no collision between Path Point 0 and 2, if it does, deletes Point 1 and repeat, if it doesn't, check between point 1 and 3, and keeps doing that till it gets to the end of the path.
 

NightFrost

Member
Yeah, that's A* based pathfinding for you. It is based on connecting neighbouring nodes, and in GM the mp grid nodes are... grid shaped. There are ways to straighten that, I think there's marketplace assets for that, and you could also try the hard way by writing yourself an A* pathfinder with Jump Point Search which straightens up the path.

EDIT - double ninja'd!

EDIT 2 - Also a thought, if you need to save on processing time (lots of enemies doing pathfinding), you can always do a line of sight check first. If there's a direct LOS between enemy and player, pathfinding is unnecessary, just head straight towards point_direction(). That's how my procgen dungeon saves on the CPU time.
 
B

Bastendorf

Guest
Lorenzo Proietti's Optimized Path asset does that!

Basically what it does, is check weather there's no collision between Path Point 0 and 2, if it does, deletes Point 1 and repeat, if it doesn't, check between point 1 and 3, and keeps doing that till it gets to the end of the path.
Yeah, A* is complicated. Mostly comprehended how it worked, though.

Yeah, that's A* based pathfinding for you. It is based on connecting neighbouring nodes, and in GM the mp grid nodes are... grid shaped. There are ways to straighten that, I think there's marketplace assets for that, and you could also try the hard way by writing yourself an A* pathfinder with Jump Point Search which straightens up the path.

EDIT - double ninja'd!
That was fast! Oh, and the script is free to boot! That explains why I couldn't find it, though... I was searching for "pathfinding". Thank you both so much!
 
Top