How to update width and setting Bottom Right to same position

I only want to update the width at runtime but Bottom Right always changes value
image

and I have tried to fix it according to this but it still doesn’t work.

my code

var grid = AstarPath.active.data.gridGraph;
            
            var currentBottomLeft = grid.CalculateTransform().Transform(Vector3.zero);
            grid.SetDimensions(GridSystem.Instance.GetX(), grid.depth, grid.nodeSize);
            var newBottomLeft = grid.CalculateTransform().Transform(Vector3.zero);

            grid.center += currentBottomLeft - newBottomLeft;
            grid.UpdateTransform();
            AstarPath.active.Scan();

Hi

You are on the right track.
Here’s how the editor does it, for reference:

Thank you very much. I got it.
I did this way

            var grid = AstarPath.active.data.gridGraph;
            var normalizedPivotPoint = new Vector3(grid.width, 0, 0);

            var currentBottomLeft = grid.CalculateTransform().Transform(normalizedPivotPoint);
            grid.SetDimensions(20, grid.depth, grid.nodeSize);
            normalizedPivotPoint = new Vector3(grid.width, 0, 0);
            var newBottomLeft = grid.CalculateTransform().Transform(normalizedPivotPoint);

            grid.center += currentBottomLeft - newBottomLeft;
            grid.UpdateTransform();
            AstarPath.active.Scan();
2 Likes