After generating my procedural map which could be any size (let’s assume 200x200), I want to change the dimensions of the GridGraph
to match.
I’ve searched through the entire GridGraph
documentations but there are some problems which I don’t know how to solve. Here’s how I do it:
_graphData = AstarPath.active.data;
_gridGraph = _graphData.graphs[0] as GridGraph;
_gridGraph.SetDimensions(Map.Instance.Size.x, Map.Instance.Size.y, 1);
AstarPath.active.Scan();
However, this somehow overrides some settings that I initially setup for the graph which I always want to be the same, for example, the 2D
option needs to be checked, and the Center
of the graph needs to be Bottom Left
and set to (0,0,0)
which I have no idea how to change through code.
Here’s what I start with and what I want to achieve (I only really want to change the width and depth):
But here’s what I end up with after calling the code above:
I’ve tried using RelocateNodes
but that either completely messes up the rotation or unchecks the 2D
option.
So - my question is:
How can I just change the width
and depth
and leave all other options the same AND if need be later, how can I change the Center
pivot so it says Bottom Left
, like in the inspector, but through code?