three-pathfinding icon indicating copy to clipboard operation
three-pathfinding copied to clipboard

Conditionnal Navmeshes [help wanted]

Open agardes opened this issue 4 years ago • 5 comments

Hello,

First thanks a lot for this awesome plugin. This is not an issue per say, but maybe someone could help me find a solution. I have a navmesh for all my scene, when the user interacts with some buttons, new objects appear on the scene. Problem is : if I incorporate those objects in my navmesh on Blender/Unity, the Player won't be able to walk through those areas while they are empty. And obviously, if I don't, the Player can pass through them once they're on the scene.

What would be the best solution to handle those kind of conditionnal navmeshes ? I was thinking of create N different navmeshes and load them dynamically but that doesn't sound like the best idea.

Thanks a lot!

agardes avatar Jul 22 '21 14:07 agardes

If you are talking about a single player game with doors, then you can create two navmeshes: one with closed doors, and one with open doors. Then you can switch between the meshes while one door is open.

dirkk0 avatar Jul 22 '21 14:07 dirkk0

Thanks @dirkk0 for your quick answer. I'm more talking about a game where when the user press a button, objects fall from the sky and then stay on the ground. So you confirm that the best solution would be to create N differents navmeshes?

agardes avatar Jul 22 '21 14:07 agardes

I can't confirm because I dont know the value of N. :) I probably would go with a mix of a navmesh with additional collision detection first.

dirkk0 avatar Jul 22 '21 15:07 dirkk0

Because there'll be 3 differents dynamic elements, N would be 8 differents navmeshes :) Seems doable but not the best idea indeed. I'll have a look at collision detection, I just want to avoid Physics for now. Thanks again !

agardes avatar Jul 22 '21 15:07 agardes

Yeah, other than getting creative with some additional navmeshes, I don't think this library can support what you describe now. The Recast Navigation library supports this better with "temporary obstacles", but is also more complex to set up and use. I'd be interested to see examples of it on the web, but I don't know of any.

I think supporting temporary obstacles (at arbitrary positions like Recast) directly in this library sounds pretty complex, although I'd welcome you to look into it if you're interested. A simpler option might be to create an API for a vertex bit mask. Assigning meaningful integers to navmesh vertices for categories like "DOOR1", "DOOR2", or "LAVA", and then call findStep() with a bit mask based on which of these the user is allowed to traverse:

const path = pathfinding.findPath(a, b, ZONE, groupID, mask.DOOR1 & mask.DOOR2);

This would require some creative vertex color or weight painting in Blender though, not something a navmesh tool will bake out of the box.

donmccurdy avatar Jul 22 '21 16:07 donmccurdy