Characters avoiding each other in turn based game

I’m making a turn based game using a GridGraph and would like the units to be able to walk around each other, they shouldn’t be able to pass through one another. Each node corresponds to a map tile and each character is one tile big.

I’ve got it working at the moment but I don’t like it as it is fiddly. Each character sets the node they are on to be unwalkable (using a custom GridGraphObject). This means units will path find around each other but also means I have to set the selected character’s node to walkable before doing any pathfinding otherwise it doesn’t work. I can’t say I’ve noticed a performance hit because only one character moves at a time but the code is easily broken if the graph update events don’t fire properly when I change code.

From what I can tell, here are my two options:

  1. I’m using the free version but I’ve seen that the pro version has local avoidance. Would this fit my bill? If this could dynamically make nodes appear unwalkable because a character is on it then that is what I’m after. I would also like to have characters of different sizes (e.g. 2x2 or 3x3) which I’m not sure is possible with this framework. Would this be able to handle that too?

  2. There is a post (Ignore self during Pathfinding) that mentions using tags for the players but I am intending to have a massive map with probably hundreds or even thousands of characters.

I appreciate your input,
Farran

Hi

Sorry for the late answer.

Currently the way you do it is the easiest and most stable way to do it (unfortunately) if you cannot use tags.
I am however working on a better system which should be able to handle an arbitrary number of units and obstacles with different sizes (when planning paths they will still be assumed to be 1x1 nodes however).

Local avoidance is not what you are after. Local avoidance does not affect pathfinding in any way.

Graph updates are guaranteed to be applied before the next path starts calculating (unless there is a bug) assuming “Limit Graph Updates” in A* Inspector -> Settings is disabled.