A moving navmesh?

Ello, ello, ello.

Rightio, I have myself a navmesh setup on a floating platform, a floating platform that moves. It would seem however that the navmesh doesn’t move with the platform.

Is there anyway to rectify this?

Cheers, big ears.


You can actually move graphs during runtime. It is currently bugged for grid graphs (search this forum for workaround), but for navmeshes it should work good.
The RelocateNodes will do the heavy lifting. You pass it a matrix, and ensures that all nodes are translated according to that matrix.
For example you could use transform.localToWorldMatrix to make the graph relative to a specific transform object.

//Translate the first graph AstarPath.active.astarData.graphs[0].RelocateNodes (...);

This is an O(n) operation (where n is the number of nodes in the graph), so I do not recommend calling it every frame, but it should be able to handle a few times per second.

A harder problem is that the paths the AI’s get back will be relative to the graph as it was when those paths were calculated. You will have to find your own way of making the AIs follow paths correctly even though the underlaying ground is moved.