Hi,
I’m making a turn-based game, where each unit will move one after the other. I have to handle differently-sized units, and have to be sure units don’t block themselves. After reading the docs, I thought that the simplest approach for me would be:
- When I place a unit on the map, I make all the nodes it occupies unwalkable (just by setting the walkable variable to false)
- Just before I compute a path for my unit, I set the same nodes to walkable = true
- I compute the path
- Once the path is complete, I set the nodes of the unit unwalkable again.
I’ll then use a custom ITraversable to check for units of different sizes (but not implemented yet, though, so this is not the problem here).
So when I put a unit on the map, I set all its nodes to unwalkable. The problem is that even if I set back its nodes to walkable again before calculating the path, the path will always return a 1 node path, as it the unit was still blocking itself. I even tried to only have a 1x1 unit, and it still behaves like this. The gizmos in the editor show me the nodes are walkable though, as expected.
I tried to call CalculateConnectionsForCellAndNeighbours() every time I change the walkable value, but to no avail. I even tried to delay the call to the path creation, in case the system would need some time to update the walkable states, with no more success. It looks like once a node has been made unwalkable, I won’t be able to make it walkable again for the path finder.
Am I doing something wrong, or is it a limit of the system?
Thank you very much for your help.