Tags and Navmesh Cuts

I’m trying to create a dynamic object that applies a tag. I may be on the right track, or missing a feature that does this, or I may be using the wrong graph entirely.

Imagine a little physics box, and when moved it applies a tag only to it’s local geometry, where it acts just like a navmesh cut does except it applies a tag instead of cutting the graph out. I want floating entities to be able to ignore these ‘cuts’, and I want walking entities to WANT to avoid them but be able to march through them if it’s the only way.

I currently have on my box: a Navmesh Cut (which cuts out and ‘adds geometry’) and then a GraphUpdateScene/SceneGraphUpdater which applies a tag to the local vicinity.

This is a bit glitchy and buggy because not only do these two features update at different rates (which could be managed I know) but if you have two boxes and move one of them into the vicinity of the other, the moving one overwrites the updates that the other one had made. So I have some questions:

  1. Is there some functionality that does exactly what I need? I’ve looked and don’t see anything that jumps out as for this intended purpose.

  2. My levels are procedurally generated at runtime. Is the recast graph even the right graph for me, or is what I’m trying to do better suited for a different type of graph?

If you need to combine tags and navmesh cutting, it is therefore strongly recommended to use the RecastNavmeshModifier component to apply the tags, as that will work smoothly with navmesh cutting.

So I think that’s basically the answer to number.

For number 2, I think a recast graph is totally fine. But you may also want to look at this page for more information/ideas.

Thanks! I messed around with this some and now remember messing around with it a while ago. From what I can tell, this RecastNavmeshModifier isn’t able to accomplish what I need.

If I have a RecastNavmeshModifier included in the scan, it considers the object as part of the walkable surface, like all the dropdowns mention. That isn’t what I need - from my example, a crate shouldn’t be a walkable surface. What I need is for the crate to create a cut in the walkable surface and apply a tag to that cut.

On the RecastNavmeshModifier, the only option that uses tags is “Walkable surface with tag”. If you put this on a crate in the middle of the floor and then scan, the entire nav mesh becomes a dome over top of the crate, and the top of the crate gets a tag.

From my testing so far, a NavMeshCut component is no help. The behavior from before (either includes in the walkable surface, or completely excluded in all ways) is used, and then the cut is applied after that.

I see this in the documentation below where your quote was from:

You can also apply tags and penalties using a graph update after cutting has taken place. For example by subclassing a navmesh cut and overriding the UsedForCut method. However, it is recommended to use the RecastNavmeshModifier as mentioned before, as this is a more robust solution.

That is in reference to this:
/// <summary> /// Called whenever this navmesh cut is used to update the navmesh. /// Called once for each tile the navmesh cut is in. /// You can override this method to execute custom actions whenever this happens. /// </summary> public virtual void UsedForCut () { }

Which is fair, I just haven’t the faintest idea how to apply a tag to the cut without trawling through the code and making guesses. Any guidance would be appreciated.

Ahh okay I see how this is coming together now. So I played around with this myself and it seems like it mainly comes down to having your NavmeshCut set to isDual and, at least for what you’re trying to do, I found GraphUpdateScene to work best when I tested it. You’ll just have to call it after your NavmeshCut is done (which you could do with UsedForCut()).

So yeah I think you were on the right path from the getgo. I guess for your second question I’d say that you may have better luck with this on a Grid Graph. No need to cut, just have the GraphUpdateScene on the crate alone and scan it. I don’t think this is a “perfect solution” either though sadly.

1 Like