A* Pathfinding Project

Navigate through center of a corrider


#1

Hi, I’m trying to navigate through a building via A*, It works well but the only problem is it chooses the corners to navigate despite what I’m looking for is a way to navigate via center of the corridors. I can do something like that via “Thick Raycast” or “Collision Testing” and increase the “Diameter” or “Height/Length” but the problem is either of these ways will block the doors and entrances and are not a good option on navigating in building floors.
I’ll appreciate if you can help me with this.
Thanks


#2

Hi

What you could do is to activate tags based on the distance to the walls (see https://arongranberg.com/astar/docs/gridgraph.html#erosionUseTags). Then you can set different penalties on the seeker for different tags. So the tag closest to the wall could have a penalty of 10000 and the next one a penalty of 5000 and so on for example. This will make it strongly prefer to walk in the center of the corridors, but it will still allow it to pass through narrow entrances (even though it will prefer to use wider entrances if there are any).


#3

Thanks very much Aron
I tried your tips and I can see different colors around my walls when my debug is on tags but when I switch my debug mode to penalty it shows everything in green mode and penalties doesn’t seem to be applied to the floor.
I have set my “Erosion iterations” to 5, and “First Tag” to 1 , and also position penalty to “Offset” 1 and “Factor” to 10 and also have set 50000, 10000,5000, 1000 to tags of 1 to 4.
I’ll appreciate if you can also help me with this.
Thanks
16%20PM


#4

Hi

The penalty that you set for tags (on the Seeker component) will not show up using the ‘Penalty’ visualization because they are agent specific.
What is the node size of your graph?

You can also use the debug mode G score or perhaps F score to see how the search progresses. Also enable ‘show search tree’ to make the visualization easier to understand. The G score is the cost from the start node to the given node and F score is the estimated total cost of the path when the search reached a given node.

Are you sure you have set the tag penalties on the Seeker that is doing the path calculation in this case? Also, are you sure that you are using the Seeker’s path calculation methods and not calling methods on the AstarPath class directly, as that will bypass the Seeker. If you are using a built in movement script like AIPath then those always use the Seeker.


#5

Thanks very much Aron,
I have attached the AIPath and Seeker scripts to my A* gameobject. my node size 200*200 on PathTypesTest scene.
I think I have been using the AStar pathfinding methods and it was overriding the Seeker script. As I see in the script it is “AStarPath.StartPath§”
I’ll also appreciate if you can help me on how to do it with AIPath and Seeker scripts.
Thanks very much


#6

Hi

If you just want to move the character, then setting the ai.destination property to wherever you want it to move will be enough (alternatively you could use the AIDestinationSetter component to make it move to a Transform, if you set the destionation property make sure you do not also use the AIDestinationSetter component though).