Hello,
(I’m sorry for asking what I presume is a terribly amateurish question, but I honestly tried tweaking and toggling every setting and option I could find, and I still couldn’t figure out how to do this on my own…)
I built a primitive environment out of cubes, and created an A* grid graph. While testing pathfinding through the area, I noticed that I was unable to get very close to the cubes, and unable to fit through tight spaces even though my character’s collision should definitely be able to fit through. Here is an example:
The red lines should definitely be able to connect there; they are leaving so much space between themselves and the cubes, which is not desired. How can I instruct A* to allow the grid graph to get closer to colliders? It’s preventing my character from moving through the environment as desired…
(A feature of the game is the ability to make the character flatten up against a wall. To achieve this, the character should be able to rub right up against the wall…so it’s okay to let A* pathfind right up against a wall. I just don’t know how to make it do that…)
The settings controlling how close to the wall the nodes will be is called “Diameter” (in Grid Graph Settings -> Collision Settings) and “Erosion” (just in Grid Graph settings). However erosion is most likely set to zero already (and you cannot set negative values).
Another good idea is to decrease the node size which will enable the nodes to follow the walls more accurately.
A third option is to switch from grid based graphs to navmesh based graphs since navmesh based graphs offer a whole lot more precision in where the border of the graph is, but if this is feasible depends on your game.
Decreasing the node size did the trick. Thank you!
I have another question, if you have the time to answer…
Here is a top-down view of my 3D environment, with a grid graph: http://i.imgur.com/MIU82.png
The purple area is the area that the player should be able to walk around in. It’s one big flat surface. Every other colored area is an obstacle that is at least 2 Unity “units” high. How do I prevent A* from drawing grids on objects that are over 1 unit high?
You cannot really. However what you can do is to mark those objects as obstacles by placing them in a layer which is included in the grid graph’s collision mask. Then the collision detection will find them and mark the nodes as unwalkable.
That’s a fine solution! Thank you very much!