Well. Currently it is possible to move the graphs around, but it is an O(n) operation, so it won’t be very nice to the CPU.
Cheating to the rescue!
What you could do instead is to create a graph for the ship at some position in the world (keep track of it). Then right before you request a path, is to multiply the target and start points with a matrix which translates the on-ship-position to on-graph-position. This way, you don’t need to move the graph around, you simply do everything in ship-space instead of in world-space.
`
//Assume this is attached to the ship root at a position so that it would be the center of a grid graph
//class: ShipData
public static Matrix4x4 shipMatrix;
public void Update () {
//Assume first graph
GridGraph graph = AstarPath.active.astarData.graphs[0] as GridGraph;
Matrix4x4 m2 = Matrix4x4.TRS (graph.center,Quaternion.identity,Vector3.one);
shipMatrix = m2 * transform.worldToLocalMatrix; //hm, maybe switch order
}
`
`
//Movement script
public void StartPath() {
// To graph space
Matrix4x4 m = ShipData.shipMatrix;
seeker.StartPath (m.MultiplyPoint(transform.position),m.MultiplyPoint(target.position));
}
…
public void Update () {
…
Vector3 targetPoint = p.vectorPath[…];
//Revert to ship-space
Matrix4x4 m = ShipData.shipMatrix.inverse;
targetPoint = m.MultiplyPoint(targetPoint);
}`
I haven’t tested the above code, but hopefully you will get a grasp on the main idea.