Recast : showing recast graph during play + need for scan?

  • A* version: [5.2.5]
  • Unity version: [2022.3.54]
    Hello!

I have mainly 2 graphs, no idea if it is linked to my difficulties :

  • 1 for vehicles (firetrucks), grid graph
  • 1 for humanoids (firemen), recast graph
    I have a lot of difficulties with the humanoids movements, and already read twice a good part of the docs.

First : how do I see the RecastGraph when Unity is playing (in the editor) ?

  • when I am not playing, it works fine.
  • during play, even if I checked “show graph” i don’t see the mesh. it’s hard to debug. I am pretty sure it is obvious, but i can’t find it. Please note I some navmeshcut.

Second Question :
I attached navmeshcut to the vehicles. It targets the good graph (the one with firemen).
Also, at the beginning there is no firemen. The vehicles arrives at the scene, go on parking place. The vehicles do not move after that in my tests. And later are the firemen on the map.
So there was plenty of time to update the graph I think.

But then, when firemen wants to move, they either :

  • get stuck against the vehicles
  • go through the vehicles
  • avoid correctly the cut.

Example : fireman 1 goes through 2 vehicles and get stuck on 3rd vehicle. If I help him, he will then avoid correctly the 4th vehicle.

I tried with RichAI and RVO, RichAI no RVO, simple AIPath, simplemodifier with/without RVO.
I always get one or two guys stuck.

I saw once that the generated path (after FunnelModifier) was going through a “no graph” part.

So should I call regularly the “scan the graph” myself ?
I thought the navmeshcut was doing that already (even once per second is vastly enough in my case).

Best regards,
Pierre

I have a first answer for the guy going through the vehicles : I should have taken rotation and scale into account in the navmeshcut.

More importantly : if i could see the graph, I would have understood that sooner. But How T_T ?

As long as Gizmos are enabled, you have the object with your AstarPath component selected, and that graph is set to visible you should be able to see it even in play mode. Can you confirm all three of these are true? If it’s still not working we can figure it out from there :+1:

With Navmesh cut I don’t think you should need to- what’s the order of operations for when the graphs are created and units are spawned?

Actually, fixing the gizmo issue may help shed some light on the issue with units going through the vehicles so lets fix that first and return to the Navmesh cut issue when we can see what’s going on in the graphs better.

“As long as Gizmos are enabled, you have the object with your AstarPath component selected, and that graph is set to visible you should be able to see it even in play mode.”

Unfortunately, this is what I did. Yes, also I have checked the “show the graph” in the bottom of the component, and in the little debug window. The grid graph is at index 0, and the recast at index 1.
It disappears exactly when I switch active a gameobject of a vehicle (which has a NavMeshCut component). That vehicule was dynamically instanciated from a prefab a few seconds before that, but and let inactive until that moment.
By the way, in the samples scenes provided by the plugin, I can see the debug graph clearly working, even with the NavMeshCut, the way you are describing.

shed some light on the issue with units going through the vehicles.

At least the going through vehicle is corrected for me. I debugued it by drawing myself hundred thousands of coloured points where I sampled the closest distance to the recast mesh. I realized the rotation was not taken into account for my navmeshcuts : I was missing “Rotate and Scale” option on the navmeshcut.

With Navmesh cut I don’t think you should need to

Thank you for that answer, this is very appreciated.
1/ the graph is already scanned. Some navmeshcuts are already there in the scene, they won’t move at all during play.
2/ then I instanciate the vehicles, they are disabled.
3/ then I instanciate the npcs, they are disabled.
4/ then vehicles are following path on gridmesh, and use NavMeshCut targetting the RecastGraph.
5/ then vehicle parks and do not move anymore.
6/ later, the NPC are shown, and follow some path.
Also, I have changed heavily my physics 3D and I feel like there is no problem at the moment of NPC getting blocked.

Best regards.

Oh that’s interesting. Thanks for the clarification. And I’m assuming there’s no issues when Navmesh Cut is disabled on that object as well before spawning it. So what if you add Navmesh to something else, does that produce the same issue? Can you screenshot your Navmesh settings for that object?

Also I’m not following the quoted parts of your reply, where are these quoted from?

So what if you add Navmesh to something else, does that produce the same issue?

If I add the Navmesh to something else, there is no issue. You are right. Now I think the error is coming from somewhere else.
I wrote “It disappears exactly when I switch active a gameobject of a vehicle”. But now, i realise this not true :

  • the navmeshcut is probably not the cullprit
  • if i simply switch the gameobject active, the graph is still visible
  • the recast graph disappear exactly when I set a destination to the AIPath component (but the vehicle is moving on the grid graph).
  • Also, If I move the vehicle by dragging with unity editor instead of using AStar component, then the graph is still visible and the navmeshcut is working OK.

Also I’m not following the quoted parts of your reply, where are these quoted from?

For the quoted parts, I made mistake using quotes, sorry. I had misunderstood the quoting system. I have edited my previous answer so that only what you told me is correctly quoted, not my answer.

Can you screenshot your Navmesh settings for that object?

I have made screenshot of the vehicle inspector and will try to upload it, but not certain I can.
Best regards,

Thanks for this breakdown :smiley: At which point does the graph disappear? When are vehicles enabled?

Can you show me the code that handles this?

I saw you were using very high values for the NavmeshCut size, on account of your small scale. I tried to see if that was causing issues but it seems fine on my end- I’d say this may still be worth looking into as well. Are your other units you’re not having issues with also .01 scale?

Thank you for that catch.
We had a mix a vehicles with 0.01 size and other with 1. We changed everything back to 1, and corrected the various values.
The graph still dispappears when I set the destination :
vehicule.mPathfinder.destination = target;
I don’t even have to write SearchPath, it disappers on that line exactly (I commented the rest after that).
Best regards.

Out of curiosity what if you use a different graph? If you make a new Recast Graph with only maybe the size of it changed, and then use the vehicle to cut that, does it work fine?