I might be missing something on the documentations, but I’m having difficulties finding the appropriate code/settings to modify to make the A* Pathfinding accurate/take into account of the pathfinder’s collider.
The green rectangle drawn in green is the actual collider for the character (Box Collider 2D). The green line is the pathing waypoints drawn from A*.
What should happen: The green rectangle should remain inside the blue lines (walkable nodes). However, the above screenshot shows that the green rectangle has already passed the walkable nodes and is colliding with the object. In real time, the character slowly moves down to the next waypoint, but it’s not smooth because it’s constantly colliding with the object to its right, somethings it’ll move up and down because A* searches for a new path.
How do I make it so A* takes into account of the pathfinder/seeker’s collider? I feel like I’m missing something in the documentation that will solve this problem.
The first thing to note is that the lines that you see are the connections between nodes, node the border of the graph. So from the graph’s point of view it is completely valid for the center of the character to be anywhere on those blue lines.
To increase the size of the margin the graph has you should tweak either the Grid Graph -> Collision Testing -> Diameter setting or the erosion iterations setting. But prefer the diameter setting first since that is usually more accurate.
You may have to increase the resolution of your graph however since currently it looks like it doesn’t have enough resolution to be able to accurately take the environment into account (Grid Graph -> Node Size).
Thanks for the quick reply! I assume for every new agent with different sized colliders, such as a large boss or car, will require a new grid graph with its own collision testing settings? Is it possible to have more than 1 active grid graphs?
For example, a small enemy can fit through some ‘cracks’ and that’s the shortest path to the destination whereas the big enemies needs to go around the ‘cracks’ to reach the destination. If I were to use the current grid graph settings, the large enemy would move up and down between the cracks and not go around it.
In another words, is it possible for each agent to have its own collision testing or can multiple grid graphs be active at the same time for different agents?