GridGraph does not want to change node count from script

I have problem with GridGraph, it only works half way. So at this page -
http://arongranberg.com/astar/docs/class_pathfinding_1_1_grid_graph.php
location
“Configure using script”
GridGraph is working with -
gg.nodeSize = 1; or
gg.center;
all fine, but when I try to change node width or depth, it does not change.
aka - this part of the code.
gg.width = 50;
gg.depth = 50;

My code!

void SetupAStar()
{
Bounds bounds = new Bounds(transform.position, Vector3.zero);
foreach(Renderer r in GetComponentsInChildren())
{
bounds.Encapsulate(r.bounds);
}
Debug.Log(bounds.extents);
AstarData data = GameObject.Find(“A*”).GetComponent().astarData;
GridGraph gg = data.gridGraph;
gg.center = bounds.center;
gg.width = (int)bounds.extents.x;
gg.depth = (int)bounds.extents.y; //It doesnt matter If I use this code or raw numbers. gridgraph does not change depth or width.
AstarPath.active.Scan();
}

Does any one can spot whats the problem? Why GridGraph does not change width or depth? The width and depth node count does not change.

EDIT : Found my solution - > Unable to set gridgraph height and width from code

1 Like