A* Pathfinding Project

Move unit in straight line without falling in holes


#1

I would like to make a unit move along a straight line without falling into the potential holes down that path. How can I do this?

I do not want this unit to be able to fall down holes. I would like that it stops moving forward more if there is a hole in front of it.

If I simply set the destination and use the standard way of pathfinding, the path could potentially not be straight.
I am using a custom controller to move along a linear path, but it does not detect the holes.

Additional question: Is there a way to know if there is a straight path to a certain position?


#2

Hi

You can use a graph linecast. See

https://arongranberg.com/astar/docs/gridgraph.html#Linecast for grid graphs
or
https://arongranberg.com/astar/docs/navmeshbase.html#Linecast for recast/navmesh graphs.