Hello,
I am trying to rescale a grid graph based off of user input at runtime. I have read answers to similar questions but have not been able to successfully update the graph. I am currently using this code:
` GameObject A = GameObject.Find ("A*");
AstarPath astar = A.GetComponent("AstarPath") as AstarPath;
astar.Awake();
Pathfinding.AstarData data = AstarPath.active.astarData;
Pathfinding.GridGraph gg = data.graphs [0] as Pathfinding.GridGraph;
//Pathfinding.GridGraph gg = data.AddGraph(typeof(GridGraph)) as GridGraph;
gg.width = maxCols*mazewidth*2;
gg.depth = maxRows*mazewidth*2;
gg.nodeSize = 0.5f;
gg.UpdateSizeFromWidthDepth();
AstarPath.active.Scan();`
I am accessing the first graph instead of creating a new one because I already have a gameobject with the Astar Path script on it which has a grid graph already created as well. Also, this code is called in the Awake() function.
I confirmed through debug statements that the graph was being updated through the UpdateSizeFromWidthDepth call, but that change was not reflected in the inspector or game gizmos.
The other answers seemed to say that what I have is the solution but I can’t seem to recreate that. Any help would be appreciated.
Thank you