Multiple enemies of different sizes

Hey, guys. I’ve just started a small project to learn how to use pathfinding with 2D.

I have multiple enemies of different sizes, and they all use the same grid for paths calculation. The big enemies are trying to squeeze between 2 obstacles, where they wont fit.

Should I create multiple grids for each enemy size or can I change pathfinding logic to take into account the enemy size?
Is there an easy way to generate different paths for enemies of different sizes?

Hi

You can use
http://arongranberg.com/astar/docs/class_pathfinding_1_1_grid_graph.php#af156f09628f08d32091ea67e48e42b71

Thanks! Missed that in documentation, sorry. Works cool btw, thanks!

Another question: is there any way to count other units on the scene as obstacles or create some moving obstacles? Do I need to update graph in each FixedUpdate?

Hi

You cannot make other units count as obstacles (well, you can. Some have had success with it, you can search the forums, but I usually do not recommend it). Moving obstacles is not a problem however. Check out the “Terrain” example scene which has a moving obstacle on a grid graph (assuming you are using a grid graph this will work).