Luke Pierson
Member
Hey there! So my game uses an mp grid for pathfinding. I had it so that each unit in the game is the size of a single square on the grid, but then I decided that I wanted a little more organic feeling movement, so I made it so that each unit takes up a 3x3 space on the grid. My issue now comes with the pathfinding. The path is generated from the central square of the unit and goes by each individual square, which is good because that will offer the more fluid movement I'm after, but because of that, the first step on the path is in a square taken up by the unit itself. So the unit can't move because it's colliding with itself. I could just remove itself from the grid, but then things will be able to just pass through it. Anyone got any ideas on how to solve this?
Also, when moving, I have my game check the squares along the path to see if they're open. I want to check all the surrounding squares too though now that my units take up more than a single square. So I'm wondering if the best method to do this is just checking by offsetting the coordinates and check multiple times? Or is there a better, more efficient way, like checking squares equal to the height and width of the unit?
Sorry if this is confusing, wrote this up really quick. I can elaborate more if clarification is needed. Thanks in advance for your help!
Also, when moving, I have my game check the squares along the path to see if they're open. I want to check all the surrounding squares too though now that my units take up more than a single square. So I'm wondering if the best method to do this is just checking by offsetting the coordinates and check multiple times? Or is there a better, more efficient way, like checking squares equal to the height and width of the unit?
Sorry if this is confusing, wrote this up really quick. I can elaborate more if clarification is needed. Thanks in advance for your help!