 Beck
|
Hi,
I am using a grid graph for my project which I need to relocate at times during runtime. I have been trying to use RelocateNodes but I’m not entirely sure how it works (the documentation on this function seems sparse). I essentially need to offset the entire graph along one axis by a float value.
I have tried sending it TRS matrices but so far I have not had any success. I am not sure what Old Matrix and New Matrix represent. Is Old Matrix something I can access from the grid graph which already exists?
Thanks,
-Beck
|
 Aron Granberg
|
I haven’t used the RelocateNodes function for some time.
But looking at the code it looks like the newMatrix is the only one used for NavMesh Graphs. It describes the offset to apply to the mesh’s vertices from the original vertices got from the mesh data.
The navmesh graph internally constructs the matrix like this:
matrix = Matrix4x4.TRS (offset,Quaternion.Euler (rotation),new Vector3 (scale,scale,scale));
For other graphs, like Grid Graph. The “old matrix” is the matrix the nodes are currently offset by.
The current matrix can be got by myGraph.matrix which is stored for all graphs (perhaps not List Graphs though…).
However, it seems there is a but when working with Grid Graphs. See here: http://www.arongranberg.com/forums/topic/relocate-nodes-fix/
Got to fix that bug.
You should call it after scanning, i.e in Start or Update, not Awake.
|