Pathfinder¶
Implements A* algorithm:
- with one modification that target point can be located not only in a node but also in some point between 2 nodes.
- Works on graph constructed with Entities and uses following components: Node (a vertex), Edge (a line that connects two nodes) and EdgeRef
- Heuristic and cost modifiers have to be provided externally by providing own module in exchange or in addition to PathfinderBasicEuclideanModule
.
- Can be used directly, but preferred way is to create request PathfinderRequest
which is processed by the PathfinderSystem
.
How to add in bootstrap¶
AddModule<ConnectionsModule>(); // requires also connections module because it provides the graph
AddModule<PathfinderModule>();
AddModule<PathfinderBasicEuclideanModule>(); // can by replaced, or you can add more cos modifiers.
How to provide custom cost modifier¶
See how PathfinderBasicEuclideanModule
, EuclideanDistanceHeuristic
and EuclideanCostMultiplier
are made.
How to request a path:¶
Entity requestEntity = EntityManager.CreateEntity(typeof(PathfinderRequest), typeof(MyTag));
PathfinderRequest request = new(requestEntity, start, target, 5f);
EntityManager.SetComponentData(requestEntity, request);
How to wait and read the result:¶
- Make a query
- iterate over entities,
- remove the path if don't need it anymore. or: