Ship AI navigation around mesh island

Hi,

I have lots of islands in my game that are constructed by small meshes, and there is one water layer.
I set the water layer as a navmesh for the AI ship, but when I instruct the ship to move to the opposite side of the island, it doesn’t go around the island, but chose to try to go across the island instead.

I set every single island mesh as navigation static, and also tried to add a navmeshmodifier for the island to be unwalkable by the ship agent. However that didn’t help as the ship still wants to go across it.

Is there a way that I can perhaps “carve” the island, so the ship would be smart enough to know where it can go, and where it can’t?

Thanks!

You can add a NavMeshObstacle script to the islands and set it to ‘carve’ mode. But this shouldn’t be necessary if you have NavMeshModifiers on them.

Have you checked the navmesh once it’s built to see if there are ‘holes’ where the islands are?

1 Like

I’m not sure if the obstacle carve can work on complex shapes? As far as I know it only offers capsule and box shaped obstacle carve. That doesn’t work on an island which is shaped randomly based on mesh heights.
Also an obstacle would apply to all agent types I suppose? I want player to be able to navigate on the island when they are not on a ship, and when they are on the ship, they will navigate on the ocean and avoid islands.

My current navmesh doesn’t have any holes around the island, and yea I want those holes lol.

So it looks like the navmeshmodifiervolume works only if it’s under the navmeshsurface hierarchy. (i.e. if the navmeshmodifiervolume is inside a gameobject that’s in parallel with a different gameobject that contains the navmeshsurface, it will not work)
I guess from this, I can supposedly add a navmeshmodifier component for every mesh I generate that would construct the island. This will require a really large amount of navmeshmodifier if my unit mesh is small. I’m not sure if that has any impact to performance.

I use the NavMeshSurface component myself, and it doesn’t require the objects with modifiers to be children of the NavMeshSurface object for them to affect the navmesh.

I’ve noticed no performance hit at runtime with hundreds of objects with NavMeshModifiers in the scene.