Modifying A* pathfinding based on size of moving object

by Darin Beaudreau   Last Updated September 10, 2019 02:13 AM

I've implemented basic A* pathfinding in my top-down 2D game, and I'm almost ready to test it, but I thought of something while adding the movement code to my enemies that I think could affect the pathfinding.

My tiles are 64x64 px, and most enemies are as well. However, I do have some boss monsters that are larger than that. My initial thought was that to move to their goal, they have to move toward each node in their path, and to determine whether they've arrived at that node and to start targeting the next node, I need to test the distance between the enemy and their current target node. So what happens if, for example, their next node is next to a wall, and because of their size, their center is too far to "reach" the node?

My solution to that would be to check if the distance between their center of mass and the next node location is less than half the enemy's width plus maybe 10 px. However, what if one of their movement nodes is in between two tiles, and they're too large to fit through the two objects the node goes between? Is there a simple way to modify A* that takes size into account?

Related Questions

Updated April 12, 2016 08:05 AM

Updated April 26, 2015 20:05 PM

Updated May 05, 2016 08:05 AM

Updated September 24, 2016 08:07 AM