• Hey! Guest! The 37th GMC Jam will take place between May 28th, 12:00 UTC and June 1st, 12:00 UTC. Why not join in! Click here to find out more!

GMS 2 mb_grid based pathfinding

The Creator

In my game I am trying to get the player's recruits to move towards an area where you click. I have the moving towards down but I can't seem to figure out how to create a pathfinder. All the tutorials I have found haven't helped at all, so I am left to ask you guys. How can I make a mb_grid based pathfinding algorithm?

That is not about the algorithm, but about how to use mp_grids. The pathfinding is handled by GMS functions, so understanding the inner workings isn't necessary. Personally speaking, I can use them with no problems, but wouldn't have a clue about dissecting how it works. Eventually you might want to make your own, but in the meantime that blog should get you started.


if (state != "MOVING"){
 if (mp_grid_path(obj_main.grid_map, path , x, y, targetX, targetY, true)){
       path_start(path, 4, path_action_stop, true);
       state = "MOVING"
       show_message("Path not found");
Here's some code from one of my test projects. It's in the step event of an object that i want to move. You'll need to create a grid and maybe change the variables but... it works and it's basically the same code that's in the link already provided. Maybe you're implementing it wrong, which is why it doesn't work for you.

Read the whole article and think about what you're doing, whether you want something to run every step or just once and go from there.


King of Raccoons

Heres a basic understanding and how to set one up
I plan on making a new video on this but i hope this helps