Small gaps in Recast grid when TranslateInDirection

  • A* version: 5.4.6
  • Unity version: 6000.3.10f1

Hi, I wonder if you can advise what I could try to reduce the small gaps appearing in my grid following moving and translating it?

It does not happen every time, so not 100% consistent.

I use this approach for performance, to try avoiding the a full scan of all the terrains.
I cannot use the ProceduralGraphMover due to the server side nature of generating the terrain in fixed positions, and I need every terrain tile to be scanned completely as it is shared with other connected clients.
Instead I emulate this by positioning the graph (works well) and then translate it back in to position to cover the newly generated terrain.

    public IEnumerator PositionGraph(float x, float z)
    {
        bool working = true;

        // move the graph at runtime
        AstarPath.active.AddWorkItem(() =>
        {
            //var graph = AstarPath.active.data.recastGraph;
            graph.forcedBoundsCenter = new Vector3(x, graph.forcedBoundsCenter.y, z);
            graph.RelocateNodes(graph.CalculateTransform());

            working = false;
        });

        while (working)
            yield return null;
    }

    private IEnumerator TranslateGraph(Vector2Int delta)
    {        
        bool complete = false;

        List<(IGraphUpdatePromise, IEnumerator<JobHandle>)> promises = new List<(IGraphUpdatePromise, IEnumerator<JobHandle>)>();
        AstarPath.active.AddWorkItem(new AstarWorkItem(
            ctx =>
            {
                var promise = graph.TranslateInDirection(delta.x, delta.y);
                promises.Add((promise, promise.Prepare()));
            },
            (ctx, force) =>
            {
                if (GraphUpdateProcessor.ProcessGraphUpdatePromises(promises, ctx, force ? TimeSlice.Infinite : TimeSlice.MillisFromNow(2)) == -1)
                {
                    complete = true;
                    return true;
                }
                return false;
            }
            ));

        while (!complete)
            yield return null;
    }

Could it be that I need to tweak my grid settings, maybe due to a rounding issue? I currently have terrains of size 128 units, and I use these values:

graph.characterRadius = 0.8f;
graph.walkableHeight = 2.2f;
graph.walkableClimb = 0.6f;
graph.maxSlope = 60f;
graph.cellSize = 0.25f;
graph.useTiles = true;
graph.editorTileSize = 32;
graph.maxEdgeLength = 8;
graph.contourMaxError = 1f;
graph.minRegionSize = 8;
graph.collectionSettings.colliderRasterizeDetail = 1f;

Thank you

This is probably caused by slope setting. When connecting voxel spans, it calculates the angle of the surface voxels. The slope here may just be higher than the value you set. You can try increasing the slope setting and see if that fixes it.

Thanks, but no its not related to slopes. Its caused by the small gaps (think character radius) that exists at the boundaries of all gaps, so I cant really do what I wanted to achieve.

Hi

Can you replicate the same gaps using the ProceduralGraphMover?