A* Pathfinding Project

Underground caves


#1

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?


#2

Could you post a screenshot of this?


#3

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.


#4

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.


#5

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


#6

Ok.

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.


#7

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?


#8

Hi

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


#9

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


#10

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


#11

Ah, okay. A navmesh cut then perhaps?


#12

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.


#13

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


#14

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