Underground caves

I’m going to have caves underneath our terrain in game. We’ll be using a transparent shader to disable portions of the Unity terrain, and a trigger to disable collisions between players and the terrain. What would be a way to allow AI to path from the terrain to the caves and vice-versa?

Could you post a screenshot of this?

I don’t have it implemented yet, but I can when I do. It’s basically though that I guess I need a way to carve out a piece of the navmesh on the terrain so that AI can pass through it to something else.

I think the best approach is probably to use a layered grid graph and then update the graph around the cave entrance when you allow the player to enter it.

I have a 3km terrain, so I think I have to stick with a recast graph for performance reasons.


Well… It will be very tricky to do this on a recast graph. You could potentially recalculate the whole tile (see graph updates section in the docs, make sure that your tiles are not too large), but that might be slow depending on your world.

What about doing a recast mesh obj to make the portion of that terrain not walkable? Would it then allow walking on the cave surface underneath it?


No, that would just prevent the agent from walking on the ground there.

Ah, so that considers anything underneath that collider as unwalkable as well, not just what is inside the collider?

Using a recast mesh obj on a surface marks that surface as being non-traversable by the agent. It will not remove the surface.

Ah, okay. A navmesh cut then perhaps?

Even with a navmesh cut it will not be able to connect to the surface inside the cave. You really have to do some tricks with colliders so that it can scan that region and get a proper opening into the cave.

Can you point me in the right direction? I’m not sure what to do to accomplish this.

To be honest I’m not really sure how to accomplish it either. It’s a very tricky thing to do.