Moves a grid graph to follow a target.
Attach this to some object in the scene and assign the target to e.g the player. Then the graph will follow that object around as it moves.
This is useful if pathfinding is only necessary in a small region around an object (for example the player). It makes it possible to have vast open worlds (maybe procedurally generated) and still be able to use pathfinding on them.
When the graph is moved you may notice an fps drop. If this grows too large you can try a few things:
- Reduce the updateDistance. This will make the updates smaller but more frequent. This only works to some degree however since an update has an inherent overhead.
- Turn off erosion on the grid graph. This will reduce the number of nodes that need updating.
- Reduce the grid size.
- Turn on multithreading (A* Inspector -> Settings)
- Disable Height Testing or Collision Testing in the grid graph. This can give a minor performance boost.
- See Also
- Take a look at the example scene called "Procedural" for an example of how to use this script
- Version
- Since 3.6.8 this class can handle graph rotation other options such as isometric angle and aspect ratio.
Flood fill the graph after updating.
If this is set to false, areas of the graph will not be recalculated. Enable this only if the graph will only have a single area (i.e from all walkable nodes there is a valid path to every other walkable node). One case where this might be appropriate is a large outdoor area such as a forrest. If there are multiple areas in the graph and this is not enabled, pathfinding could fail later on.
Disabling flood fills will make the graph updates faster.