I have tried to ask on the A* forum, but with no luck. So now I have decided to try here:
This script currently only moves the A* grid, but I would also like it to calculate the new nodes on the terrain, but can’t figure out how to make it work. I have also tried to check the procedural example, but that was what I made the following code out of. I would also prefer not to rescan the whole terrain each time, because it takes something like 90ms
function UpdatePathFinding() {
var Center = Vector3(((CurrentTileX + 1) * terrainSize) - (terrainSize/2), 0, ((CurrentTileZ + 1) * terrainSize) - (terrainSize/2));
graph.center = Center;
graph.GenerateMatrix ();
var width = graph.width;
var depth = graph.depth;
var nodes : GridNode[] = graph.nodes;
for (var z = 0; z < depth; z++ ) {
for (var x = 0; x < width; x++ ) {
graph.UpdateNodePositionCollision(nodes[z*width + x], x, z, false);
graph.CalculateConnections (nodes, x, z, nodes[z*width+x]);
}
}
}
EDIT: How can I scan a specific grid graph or only scan a certain part of a graph.