Support Forum

RecastMeshObj with dynamic not working

Hi,
I’m trying a cheap way to block seeker in recast graph, I read the RecastMeshObj 's document and it’s says that just ‘Adding this component to an object’ and ‘Check dynamic if the object will move.’
But it won’t block my seeker in dynamic mode, if I got a path by using ABPath.Construct(), it will through that block directly.
I weren’t able to find a help or example in this script. please tell me how to use it. Thanks!

Hi

If you want a cheap way to block an agent I’d suggest using the NavmeshCut component. See https://arongranberg.com/astar/docs/navmeshcutting.html

Hi,
I have already tried NavmeshCut, and I met a peak in profiler every time I active it, it cost about 1MB GC from “TerrainData.GetHeights()”, I have no idea how to avoid this. thank for reply!

That’s odd. The NavmeshCut doesn’t have anything to do with terrains. It never uses any terrain data at all.

Hi
I have a big terrain (800x800), with recast, settings down here

It told me that calculate should be very slow( But cutter should calculate tiles only in it’s bounds I think)

Picture below shows that object works

QQ截图20210210110029

I’m trying active cutter after game run and fps stabled, Now if deep profile opened, when I click ‘activate’ checkbox, the memory and CPU will be exhausted. Finally failed and output errors(memory no enough ,etc.), It shows ‘TerrainData.GetHeights()’ make tons of GC if I use a smaller terrain to watch deep profile.

please see PICTURE 1 IN NEXT POST

The system is running out of memory. Please close applications to free memory or free up space on the partition where the pagefile is located.
Used memory (physical and paged): 93% (40057MB of 43065MB).
Discarding profiler frames data.

Now I close deep profile and try again

please see PICTURE 2 IN NEXT POST

This is the result, about 300Mb GC in A* workers.

Above all, it’s only a NavmeshCut script on a empty gameobject. I use recast on terrain instead of a grid graph, because grid may not have multiple layers.

So anything wrong in my solution? please help, regards!

PICTURE1

PICTURE2

Hi

The first time any navmesh cut is used the system needs to pre-allocate data to handle navmesh cutting.
This only happens the first time. Subsequent updates are much cheaper.

You are using veeery small tiles though. I would recommend a value closer to the default: 64, 128 or 256 are usually good values.

I do not see any TerrainData.GetHeights in that profile though?

Thank for the advice, I have changed the ‘Tile Size’ to 128.
It’s weird, I cannot find ‘TerrainData.GetHeights()’ anymore. But I found the real reason of CPU usage’s peak.
I added my script on hundreds of object, which has code can update graph once.

void Start()
{
		var guo = new Pathfinding.GraphUpdateObject(Bound);
		AstarPath.active.UpdateGraphs(guo);// profiler will be steady if comment this.
}

This makes 16MB GC every 1~2 seconds.



I can’t understand why code at start can make this repeatly?

Oh, I understood, this GC collect will disappeared after all UpdateGraph work finished.

Hi

Yes, running UpdateGraphs for a recast graph will start to execute an asynchronous graph update which may take a bit of time.
I don’t recommend that you do this at the start of your game though, in that case just scan the graph as usual and it will include whatever changes those objects would have made.

Note also that the beta version (not sure if you are using it) has significantly faster recast graph updates (and less GC allocations).

Thank you again, that’s very useful information. I’ll move on!