Support Forum

Paths are clinging to obstacles on tight turns

I’ve been working on using the project to generate a grid graph for moving a long vehicle in small tunnels with 90 degree angles, and the built in seeker is hugging the sides of the available space which is causing problems when it tries to turn.
I can’t just increase the width of the grid scanning raycast capsule because it will sometimes need to go straight through tunnels that are only slightly wider than itself.
the most likely idea I have is giving each node a penalty based upon how close it is to any obstacles, but I can’t find any good tutorials on adding penalty to graphs.

any advice/ideas/tutorial links would be appreciated

some other ideas I had were:

  • make 2 separate graphs where 1 has larger raycast capsules and is a “turning graph” that will be followed if possible but the car can switch to the other graph if necessary
  • keep the grid calculation part but make a new pathfinding algorithm

I didn’t personally make the models I’m using so I don’t know if I can post a screenshot here, so I drew up a quick representation in mspaint

I found the answer on my own, for anyone else who has the same problem here is the solution I found:
put the number of cells away from the walls you want to have tags for into Erosion and then check the Erosion Uses Tags checkbox, then add the tag penalties on the vehicle’s Seeker component (the tag in the First Tag dropdown that appears below the checkbox will be closest to the wall, with the following tags being further)

I’d also recommend going down into Settings to Debug and change Graph Coloring to Tags.
you might also want to change the default colors of the tags to be more appropriate by going to Colors and modifying the custom area colors

here are screenshots of the settings I used:

and here is the result:


for future reference, this is what I set my penalty values to (I have 3 erosion tags now instead of the 2 mentioned above)
do be aware that my values are optimized around making my vehicles stay as far away from the walls as possible, other projects may want smaller ones
p.s. the cost to travel a unpenalized tile is 100 if I remember right, and the penalty is added on top, so tag 1 tiles have 6x the normal cost, tag 2 = 3x, tag 3 = 2x, tag 0 = 1x normal cost

Edit: the cost to traverse a world unit is 1000, my values are fine for me as I’ve got half sized tiles but any other projects probably should use some other values

1 Like