I have floor with recast mesh object marked with area 0
And I have a object on top which have recast mesh object with -1 area.
I only use recast mesh object to determine graph area, I don’t scan colliders or mesh (no options checked)
But when I scan the graph, I have a bit of graph being generated area inside the recast object with -1 area.
The graph is being cut ( not generated on around the border of the object with -1 area. So it is sort of working. But I was expecting it to not generate any graph for the area inside -1 object.
On my closer experiment,… even when I set my object with supposed to be -1 area setting to be 0, ( so graph should ignore my object on the floor) is doing the exactly the same thing… I am guessing that it is like that because the object itself is very tall like a wall, so it is not generating the graph around the border of the object.
So it could mean that it is just the -1 setting is not working as it should.
I have done more experimenting and found that if I move the object on top of the floor to be lower so that the top of the object is a lot more closer to the floor, it seems to work.
This led me to think about my walkable height property. So I changed it to be higher value and it now seems to work.
So my theory so far is that even if I set it to be -1 , it can only see the top of the -1 object area if my “walkable” height is high enough to cover it…
I have also tried to automated the process by setting graphs’s walkable height to 4 before I let it scan to save the nav mesh data to the file, but I can’t seem to access the recast graph for some reason.
The recast graph works by rasterizing all the faces (triangles) of the objects, it does not know what is “inside” or “outside” an object (which is undefined anyway in most cases since most meshes are not closed). What setting the area to -1 does is that it will not generate a navmesh on top of that object (on any face of that object more specifically), it doesn’t care or know about the inside of it.
So if you say had a box marked with an area of -1, it would make sure that no navmesh was generated on top of that box.
It sounds like what you really want is a NavmeshCut component.
The walkable height field specifies the minimum distance to the “roof” a part of the navmesh must have for it to be valid. So if your object is say 2 units high, then setting walkable height to 2 would make the inside of the object too small for anything to fit in there, so it will remove the navmesh there.
Don’t know about the index error though… that definitely sounds like a bug.
Do you have the exact stacktrace?
Also, you should not have to set AstarPath.active = someValue, if AstarPath.active is not set, that means the pathfinding scripts are not initialized yet. Are you trying to call this in Awake?
Ok so if my wall object with -1 area setting has height of 4 then walkable height also has to be over 4 to be able to take area inside of wall to not generate graph?
I am trying to call scan inside editor script. After i open scene i want to set my scan settings and then scan to save nav data to the file. I was able to do this without trying to set the walkable height before. I didnt need to access graph setting before and my editor script worked fine. I just need to access recast graph setting so i can force set my walkable height to be 4 instead of 2. I have 100s of scenes so i usually use editor script to automate my process.
Yes, pretty much. Setting the area to -1 will only remove the surfaces which are actually marked with -1.
Ah. ok.
Try to call astarPathScript.astarData.DeserializeGraphs ();
That will make it load the graph settings. They are not always loaded in the editor.
After I save data to disk , I also save the scene using different name. But when I open the saved scene my walkable height is still 2.
However, when I run the game and actually load the nav data along its settings, it shows correctly as 4. So generating nav data using correct setting is working ok. It is just that the unity scene that I save after changing the walkable height to 4 isn’t keeping the setting.
I have tried to set the Astar as dirty but it didn’t do a trick… So maybe I am missing something here…
Yeah, you need to store the settings too. script.astarData.SetData (navMeshData)
(you can just set the checksum to 0 or something, it is used in the editor for undo handling).
Ugh… ok. Well, I just found out that if I store settings like you have suggested, I didn’t even need to store my nav mesh data into a file and load it up… Which is… a good thing, except that I have found that out now, after I have done all the work to get it to work with offline nav mesh file loading system… hehe…