Hey using the plugin and it’s been pretty damn good!
I am wondering if it’s possible to move NavGraphs? I’m working on a runner style game where the terrain is generated on the fly and I want to only use 2 NavGraphs in tandem. So when the player/bots are off one it can be recycled and put up ahead, scanned with new obstacles, and ready to go again. Is this possible or is there another way of achieving this functionality?
Cheers
Sure, all graphs can be moved. Gridgraphs do require a workaround in the current version though since the implementation for it is slightly buggy.
See http://arongranberg.com/astar/docs/class_pathfinding_1_1_nav_graph.php#a9f94661379d6d8394f335c9add8c00a5
Make sure to call AstarPath.active.Scan after moving the graph to update the graphs.
PS: Want to support the development of the A* Pathfinding Project? Give it a rating in the Unity Assetstore and/or write a nice review about it.
Hey thanks for the quick response. I had a look at the solution but I’m a little confused about how to implement it. It says translate the centre by the same matrix used to translate the nodes. Is the centre this.matrix?
Hi everyone,
Can you please post the code that fixes the problem?
I don’t understand how to fix it - and I have seen the description from the guy who wrote it.
At the moment, calling:
AstarPath.active.graphs[1].RelocateNodes(AstarPath.active.graphs[1].matrix, Matrix4x4.TRS(positionsToPlace[1], Quaternion.identity, Vector3.one));
AstarPath.active.Scan();
does nothing on my build - the grids don’t move.
I think I may have worked it out.
Calling ((Pathfinding.GridGraph)AstarPath.active.graphs[1]).center = positionsToPlace[1];
AstarPath.active.Scan();
seems to move them - but the order of graphs I need to look into - it seems to be out of order.