GameMaker mb_grid based pathfinding

T

The Creator

Guest
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?
 
https://www.yoyogames.com/blog/459/dynamic-mp-grids

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.
 
T

The Creator

Guest
I tried that but it wasn't working with my other project.
P.S. I changed all the object names to my own.
 

Rob

Member
Code:
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"
  }else{
       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.
 

Evanski

Raccoon Lord
Forum Staff
Moderator

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