Pathfinding for Runtime placed buildings with multiple layers

Hello. So I just replaced the Unity NavMeshSurface experimental project with A* Project Pro, and it works okay. I do have one issue that I wasn’t really expecting…
My game is an fps, in a procedurally generated world- That part works fine. Now problem is, I can build stuff at runtime, from various modules. Problem is, the moment I add slopes/stairs, the AI can’t follow me up those- I Update the graphs, whenever I place stuff, and for things like walls, etc. it works fine.
I’m using the Recast Graph, as my understanding was that it would voxelize the whole thing- Here I believed that it would do that for a volume (My world has a fixed size, albeit procedural), but problem is, I can’t add ‘nodes’ as it seems (I think the documentation also mentioned this).
I noticed there’s the layered graph option, and honestly, I haven’t tried it, due to the four-direction limitation.
Also, I have ensured that the graph allows for steep slopes, I set it over 60 degrees, which my slopes are (And those worked fine with the Unity NavMesh Surface, with 60 degrees, as a reference)
So I was basically hoping someone here could help me out. I believe this isn’t that big a problem, probably just me who needs to be pointed in the right direction.
Attaching a quick screenshot here to show the slopes that the AI can’t follow on (Even the flat surfaces, seems to be a problem at times) - I’ve attached a screenshot for clarity.

So the TL:DR:
How do I ensure the AI can path find correctly, when adding new geometry essentially at runtime, adding additional layers?

Hi

Do you think you can post a screenshot of your graph? (+settings).

A recast graph might be better for you in the end, but fyi, the four-direction limitation has been lifted in the beta version.

If you do a regular graph update, arbitrary changes to the world are supported. It is only when using navmesh cutting that you cannot add surfaces to stand on.

1 Like

I took a screenshot of the graphs, and the settings, I hope that is what you meant?
The Graph


The Settings
AstarSettings01

So as soon as the scene is loaded, and I’ve procedurally placed the objects I need, I call AstarPath.active.Scan();

When I place a new ‘structure’ (like the ramp shown in the previous screenshot, I call AstarPath.active.UpdateGraphs(bounds);
All structures, are on the ‘Structure’ Layer, which is also included in the LayerMask on the graph.

Let me know if I you need more info.

So I noticed, when starting up my scene that I get the following warning, a few hundred times:
Some meshes were statically batched. These meshes can not be used for navmesh calculation due to technical constraints.
During runtime scripts cannot access the data of meshes which have been statically batched.
One way to solve this problem is to use cached startup (Save & Load tab in the inspector) to only calculate the graph when the game is not playing.

Could this be the cause? I mean I do not make any changes to the statically batched objects, but I assume the message means I cannot change the graph at runtime because of this.
Problem is… I need to make the static batching for performance reasons…
I’ll try to see if I can fix this, by making a separate graph, for the structures- Will that make sense?

Seems that was not the solution. I also tried going to rasterize with colliders, instead of the meshes. It does remove the warnings, but the results are the same - Still, no pathfinding on my runtime-placed slopes.

Hi

I meant the graph in the scene view.

The ‘spheres’ are just gizmos for my snapping system, which are on a separate layer than the structures.
The well thing in the background is a structure that are placed at loadtime (So before the graphs is ‘scanned’ - The wooden parts, are added at runtime, and done with an update afterwards. - Hope this is useful?

Hmm, it’s hard to tell, but it looks like the resolution of your recast graph might be too low. Try to lower the cell size in the recast graph settings.

I tried reducing the cell size all the way down to .1, which gave quite a long load time, but alas, no positive result- I mean I could see the mesh being more detailed, but still no pathfinding on the ramps.
We agree that I don’t need to put any type of component on the structures right? Simply have it on the ‘Structure’ layer, and ensure it’s being ‘deployed’ inside the bounds of the Recast Graph volume, no?

Yeah, that should be everything you need.

You may need to reduce the character radius setting. Might not be enough space for it to walk there otherwise.

1 Like

hah! That did it- I assumed the radius was in Unity Units? Each ramp has a with of 2 Unity units, and the radius was 1- Reducing radius to .4 in this case, solved it.

Thanks a lot for the support, now at least I can get further with this.

Consider the question below, optional- Just me being needy now that I have your attention :smiley:

I seem to have some janky pathfinding once in a while- So I use the Raycast Modifier to smooth it out, but it still seems ‘confused’ at times- I run at medium quality- Assuming I will have maybe up to 200 units in a scene at a time (In very rare edge cases though) - Should I worry about performance, or can I ramp the ‘quality’ up?