GridGraph: How to prevent agents pathing across edges

Hello! Firstly awesome package, thanks for a free version! So I’m trying to write a voxel game like minecraft but more similar to RTS gameplay (you’re a mining company mining blocks with vehicles).

The problem I’m having is I don’t know how to tell Astar to prevent an agent from pathing across different ground elevations without a ramp (dropping off edges or trying to path uphill). I thought it would be handled by the “Max Climb”/“Max Slope”:
Max Climb/Slope Settings

But that doesn’t seem to work (note: each block is 10x10x10). The agent tries to path up to the elevation above (which should be inaccessible) and clips through the colliders and falls into the abyss. It can also fall from the top to the bottom, which is not what I want to happen in this game (a mining vehicle falling down 10m onto the block below). This is what happens when trying to path uphill:

What I have tried is using the “erode” functionality, which works, but then the blocks wont be pathable at all. So I split each block into 4 so that 1 erode iteration still lets the block be pathable: 4x Split

This works but is very wasteful of resources, and slows things down a huge amount since each chunk im updating is 5x5 voxels it goes from 25 points to 20x20=400 points per chunk plus erode which I think is expensive.

How should I be solving this? The Max Climb doesn’t seem to do what I expect it to, and the agent can path both through the blocks it should collide with, and also will fall off the edges it shouldn’t be able to. I feel this would be easy to fix if I could somehow tell Astar that the cost of traversing the edge is infinite, but also allow ramps the agents can use. Any ideas what I’m doing wrong, or how I should be solving this?

Hi

The agent actually only tries to reach the edge of the tile. As the navmesh is built, the agent is allowed to move precisely to the edge of the tile. The green line that the agent follows is its path. If it happens to move even a tiiiny bit outside the navmesh it will then fall to its death, unfortunately. I don’t have a great solution for this use case I’m afraid :confused:
A recast graph might be a better solution in this case? Even though it would be a lot slower (in the beta version its a lot faster though).

Hey it’s the dev! :slight_smile: Thanks for the reply. I’m a bit unsure still though. The blocks have cube colliders, they should prevent the agent from passing through it. Also Astar must know about the heights between the different tiles - because that’s where it erodes (if set). But if it knows the heights, shouldn’t the Max Climb setting prevent Astar from finding a path from the low ground to the high ground? It’s just a massive step that should be unpathable right? Am I misunderstanding Max Climb or how is that supposed to work?

Thanks for the recast graph suggestion and note about its speed. I’ll have a look at it.

It is unpathable.
As I mentioned in the previous post, I think A* generates a path to the closest point it can reach, which is precisely on the edge of the tile.

Collision depends on if you have a CharacterController attached or not.