void
RelocateNodes
(
)
Moves the nodes in this graph.
Moves all the nodes in such a way that the specified transform is the new graph space to world space transformation for the graph. You usually use this together with the CalculateTransform method.
So for example if you want to move and rotate all your nodes in e.g a recast graph you can do AstarPath.active.AddWorkItem(() => {
// Move the graph to the point (20, 10, 10), rotated 45 degrees around the X axis
var graph = AstarPath.active.data.recastGraph;
graph.forcedBoundsCenter = new Vector3(20, 10, 10);
graph.rotation = new Vector3(45, 0, 0);
graph.RelocateNodes(graph.CalculateTransform());
});
For a navmesh graph it will look like: * AstarPath.active.AddWorkItem((System.Action)(() => {
// Move the graph to the point (20, 10, 10), rotated 45 degrees around the X axis
var graph = AstarPath.active.data.navmeshGraph;
graph.offset = new Vector3(20, 10, 10);
graph.rotation = new Vector3(45, 0, 0);
graph.RelocateNodes((GraphTransform)graph.CalculateTransform());
}));
This will move all the nodes to new positions as if the new graph settings had been there from the start.
NoteRelocateNodes(deltaMatrix) is not equivalent to RelocateNodes(new GraphTransform(deltaMatrix)). The overload which takes a matrix multiplies all existing node positions with the matrix while this overload does not take into account the current positions of the nodes.