I am currently using your procedural grid mover example and it works great. However, I need a low detail version for terrain in the horizon, but I don’t want to use colliders. I start by creating the grid using normal raycasting so I have something to work with and to make sure it generates properly, then I’m trying to update the node positions without any luck. I am using an older version (3.5.1) with the newest Unity version and haven’t upgraded since I didn’t see anything relevant to my needs. Perhaps that is the issue, since much of the documentation doesn’t seen to work (most of the AddWorkItem examples, besides those in the procedural examples)
Initialization then calling scan to generate graph
gridGraphLod = data.AddGraph(typeof(GridGraph)) as GridGraph;
gridGraphLod.center = new Vector3(player.transform.position.x, -100f, player.transform.position.z);
gridGraphLod.width = pathSize;
gridGraphLod.depth = pathSize;
gridGraphLod.nodeSize = 27;
gridGraphLod.maxClimb = maxClimb;
gridGraphLod.UpdateSizeFromWidthDepth();
gridGraphLod.collision.fromHeight = 400;
gridGraphLod.collision.mask = collisionMask;
gridGraphLod.maxClimb = 0;
gridGraphLod.collision.heightMask = heightMask;
gridGraphLod.collision.unwalkableWhenNoGround = false;
total = gridGraphLod.width * gridGraphLod.nodeSize;
gridScale = Vector3.one * total;
gridBoundsLod.transform.localScale = gridScale;
gridBoundsLod.transform.position = new Vector3(gridGraphLod.center.x, player.transform.position.y, gridGraphLod.center.z);
Using something like this I can change the walkability and it works fine, but if I do anything with node.position it breaks, well at least it doesn’t show anything in the scene view anymore. Even if I set node.position = node.position it doesn’t seem to work, am I missing something. I am also settting collisionCheck and heightCheck to false since all I want to do is change the positions for now. I don’t want to use any physics calculations on this secondary grid.
var lodGraph = AstarPath.active.astarData.graphs[1] as GridGraph;
lodGraph.collision.collisionCheck = false;
lodGraph.collision.heightCheck = false;
AstarPath.RegisterSafeUpdate(() => {
var gg = lodGraph;
var nodes = lodGraph.nodes;
for (int z = 0; z < gg.depth; z++) {
for (int x = 0; x < gg.width; x++) {
var node = gg.nodes[z * gg.width + x];
//node.position = new Int3(-1229434, -100000, -1693870);
node.Walkable = Random.value > 0.5f;
}
}
for (int z = 0; z < gg.depth; z++) {
for (int x = 0; x < gg.width; x++) { //assumed not needed, but tried using to no avail
//graph.UpdateNodePositionCollision(nodes[z * gg.width + x], x, z, false);
}
}
for (int z = 0; z < gg.depth; z++) {
for (int x = 0; x < gg.width; x++) {
graph.CalculateConnections(nodes, x, z, nodes[z * gg.width + x]);
}
}
// Refresh internal pathfinding data
AstarPath.active.FloodFill();
}, false);