- Home /
updating astar gridgraph at runtime
hi all,
Searched for an hour and couldn't find an answer. I'm using the pro version of Aron's excellent pathfinding scripts. I can't figure out how to update the size of the graph at runtime. We have a project with a single a star prefab but multiple scenes. I want to change the size of the grid as each scene loads. Specifically, I want to change the width, depth, x and z of the gridgraph at runtime, preferably via javascript. Can anyone help?
Thanks in advance
Answer by Bill 2 · Nov 16, 2011 at 01:17 PM
got there eventually
//change the size of the GridGraph
customiseAStar(500,500,250,250);
//then scan the map
gameObject.SendMessage("Scan",SendMessageOptions.DontRequireReceiver);
//the customise function
function customiseAStar(w:int,d:int,x:int,z:int){
for (var graph:IUpdatableGraph in AstarPath.active.astarData.GetUpdateableGraphs ()) {
graph.width=w;
graph.depth=d;
graph.center=Vector3(x,0,z);
graph.UpdateSizeFromWidthDepth ();
}
}
hope others find this useful
Awesome, exactly the same thing I was looking for today! Thanks! :)
Your answer
Follow this Question
Related Questions
Update mesh collider after changing vertices at run time 1 Answer
Update mySQL at game runtime ??? 2 Answers
Prefabs Transforms LookAt 0 Answers