I have just bought the pro version. So I could update point graphs at runtime. However I am actually having bit of trouble with it still. I am add nodes via script to the scene, which seems to be working just fine. Then I am trying to Update the local location of the newly added nodes using the GraphUpdateObject, but when I do this the nodes dont actually get updated connections are not applied. I also get this error (Debug.LogError(“Error while updating graphs\n”+e)not really sure why I feel as though I have followed the documentation correctly.
here is a bit of my code.
THIS CODE IS ON THE NODE ITSELF WHEN IT CREATED
public AstarPath aStarPath;
// Use this for initialization
void Start () {
aStarPath = GameObject.FindObjectOfType<AstarPath> ();
aStarPath.AddWorkItem (new AstarWorkItem (ctx => {
var graph = aStarPath.data.pointGraph;
Debug.Log(graph.name);
var node = graph.AddNode ((Int3)transform.position);
ctx.QueueFloodFill();
Debug.Log (graph.CountNodes ());
}));
}
THIS CODE IS WHAT SPAWN THE NODE AND UPDATES GRAPH
void Update () {
ray = Camera.main.ScreenPointToRay (Input.mousePosition);
if(Physics.Raycast(ray, out hit))
{
if(Input.GetButtonDown("Fire1"))
{
GameObject obj = Instantiate (node, new Vector3(hit.point.x, hit.point.y +1,hit.point.z), Quaternion.identity) as GameObject;
GraphUpdateObject myGUO = new GraphUpdateObject ();
Vector3 v = hit.point;
Vector3 boundPoint = v;
myGUO.bounds = new Bounds (boundPoint, new Vector3 (10.5f, 10.5f, 10.5f));
myGUO.updatePhysics = true;
aStarPath.UpdateGraphs (myGUO,0.25f);
}
}
}