Questions about recast graphs

Hey, I have 2 questions regarding recast graphs:

  1. When I press play (in the editor) the graph disappears, even though I have calculated it by pressing the Scan button (and the Scan On Awake box doesn’t fix the problem). I also noticed that the graph disappears after the Unity editor compiles a script. Is that by design or am I doing something wrong? For now I’ve bypassed the issue by clicking on Generate Cache (which makes the graph remain as expected).

  2. I’m looking for a way to resize (ie. change the boundaries of) a recast graph. Apparently there’s no way to select the edges of the white cube that represents its bounds. I’ve tried with all of the Unity tools (move, scale, resize, etc.). And manually inputting numbers in the Center and Size fields on the graph feels quite frustrating and imprecise, so I think I’m missing something here. What would be the simplest and most intuitive way to achieve this please?

Graph node data is not saved with the level and thus needs to either be recalculated (scan on awake) or loaded from a file (graph caching) to work. This is because graphs can contain quite a lot of data and the Unity serializer simply cannot handle it all (a large grid graph is easily tens of megabytes). Furthermore there are references and other things which the unity serializer cannot handle.
It should be automatically calculated if you have scan on awake enabled. Do you get any errors that might be helpful?

Currently there is no way to resize the graph in the scene view (I should add that). However there is the button “Snap Bounds To Scene” which will make the graph snap to the meshes inside of it.

There is a message that says: No MeshFilters were found contained in the layers specified by the 'mask' variables, even though the “Navigation” layer exists, contains the dedicated objects and pressing the Scan button actually works. So it looks like the button and the start at Awake might not look at the exact same things. Also please note that I have Rasterize Terrain to false, Rasterize Meshes to false and Rasterize Colliders to true.

Regarding using the “Snap Bounds to Scene” button it doesn’t quite work in this case because I have a super large cube-floor stretched to the horizon while my test areas are much smaller. Plus I need to test edge cases where the AI’s destination is set to off-the navmesh positions (for testing/debugging purposes).

So I would respectfully ask for a way to manually resize the recast graph bounds, please… :slight_smile:

Do you generate your level at runtime or change it somehow?

Also. Do you by any chance use any of Unity’s new beta physics engines where things are converted to entities when you press the play button?

I manually create the levels, so it’s not procedural. The changes that would happen in-game are things like doors opening, or small areas being blocked/unblocked, this kind of things.

Now regarding the new beta physics engine: no, I don’t think so. I’m using plain 2019.1.5f1 with no specific packages related to physics.

Are there any settings in the editor in 2019.1 that might affect this?

That’s strange. Scan on awake calls the exact same code as the scan button.
If you press the Scan button while the game is playing, does it generate the graph then?

Yes, scanning the graph at runtime (after entering play mode) works. The graph appears then.

Hmm… Do you think you could post a screenshot of your graph settings (the full inspector) in the configuration that does not work?

Here it is:

That’s strange. I cannot see anything at all wrong with that configuration.
Would it be possible for you to share your project with me? Then I could debug it more easily.

I was afraid you’d say that… :slight_smile: My current project is more than 50Gb (I’m starting from the structure of the previous game, pruning things little by little) and my internet connection would be incapable of uploading that unfortunately.

If you’re up for it I could share my screen with you over Skype, if that could be of any help…?

I’ll keep looking to see if I can find any clue. Maybe there’s something wrong in my project…

If you’re loading multiple scenes at the beginning (or large terrains might also cause this), the scan might be called before rest of the data is processed.

Though loading graphs from cache would definitely be recommended, super easy to do. For example:

private static void LoadNavigationGraph (TextAsset navigationGraph ) {
    if (navigationGraph != null)
        AstarPath.active.data.DeserializeGraphsAdditive (navigationGraph.bytes);
}
1 Like

(Cheers Toasty!)

I have another question regarding the Recast graph: in my tests I have cubes (which are supposed to be non-walkable obstacles) on a ground plane. But I’ve noticed after doing a scan that the ground under the cubes also gets a navmesh chunk (as can be seen on the screenshot).

That’s probably because the cubes and the ground are on the same navigation layer. But if I put the cubes on a different layer (which is excluded from the Layer Mask of the recast graph) then they’re understandably ignored by the scan.

Hence my question: Is there a way to mark some game objects to be excluded from the navmesh while sill being considered as obstacles (or at least “hole-makers”) during the scanning process?

Sounds like it might be useful at this point. If you haven’t found a solution yet.
Send me a PM with your contact info.

Right now I’m afraid there is no way to mark the inside volume of an obstacle as completely unwalkable. This is because the system just sees everything as a polygon soup. It doesn’t really know about separate obstacles or what “inside” or “outside” means. What you can do is to make the surface of it unwalkable. You do this by attaching the RecastMeshObj component and setting the parameters to mark it as unwalkable.

1 Like