Move unit in straight line without falling in holes

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?


You can use a graph linecast. See for grid graphs
or for recast/navmesh graphs.

1 Like