frist at all, nice plugin! With only a few clicks and a little experimenting I managed to have 250 enemies following my player on a parkour without even having the slightest sign of a lag.
Now to my problem
I’m not sure what Graph is the best use for this particular case:
You start on a module and each exit gets filled with another module. The modules are dynamically generated and deleted when getting near/far away from them. It is not known what kind of module will spawn where, its completely random but modular.
I read about using Regraph and Tiling with switching the Mesh but I’m not really sure if its the right strategy and how to achieve this. The world is theoretically infinite. I also tried to have a grid world which moves with the player, so If enemies enter the screen they should be on the grid and already moving, but I’m not really convinced about this way.
The easiest solution is to use the ProceduralGridMover script. You can see an example in the scene called ‘Procedural’.
Recast graphs are pretty slow to update, so I think I would avoid that.
There is no direct method (I should probably implement one), but you can do
var nearestPos = AstarPath.active.GetNearest(myPosition, NNConstraint.None).clampedPosition;
var delta = myPosition - nearestPos;
delta.y = 0;
if (delta.magnitude > 1) { // Some small distance outside the graph
// Do stuff
}
That will find the closest node on the graph (includes unwalkable ones) and checks the distance to the closest point on that node.