TowerDefense grid and path problem

Hello,

I’ve been trying out A* Pathfinding for a tower defence i’m working on, and I’ve stumbled upon a few issues I need help with.

Here’s an example of what kind of tower placement I’d like to have :

In order to do this, I use the pathfinding grid to find nodes where I can spawn new towers. My towers are 2 times bigger than the grid cells, and I want it to be possible to have a 1-cell wide path between two towers.

I setup the Erosion parameter with 1 iteration, so when I spawn a tower on a specific node, all the nodes that are directly connected to it become unwalkable. But then the enemy units can’t pass between 2 towers separated by only one cell, because there aren’t any walkable nodes left.

I tried to disable Erosion and manually set nodes to unwalkable when I place a tower on it. But in that case, enemy units actually find walkable nodes between towers, and remain stuck trying to pass (they’re blocked by the geometry).

Ideally, I’d like to be able to use the same grid for pathfinding and for placing towers, but right now I can’t seem to find a way to make it work.

Do you have any ideas or suggestions ? Am I missing something ?

I found a solution, i rotated my grid by 45° … so simple but work !

45° rotate?? Hm, interesting solution. If it works I’m not going to say anything.

You should know that the lines drawn are connections between nodes, so nodes are actually placed at the cross intersections in the graph, they are not the square enclosed between 4 lines. If you would offset the grid in the first image 0.5 nodes to the left, and 0.5 nodes “up”, it would probably work.

yep, both solution seems to work. Thanks