Support Forum

Pathfinding on Temporary Runtime Graphs

I sometimes want to perform the following operation.

  1. Create a pointGraph from a set of locations
  2. Set pointGraph properties
  3. Connect Nodes.
  4. Find a path between two positions using the pointGraph.
  5. Discard the pointGraph.

I have no problems with 1 to 3.

Currently the only way I know of doing 4 after 3 is
a. Add the graph to the AStarPath
b. Create NNConstraint with pointgraph as a mask.
c. Create ABPath with the two positions.
d. Add NNConstraint created in b.
e. Startpath.

Is the above a to e the only way to achieve 4.?
I just want to use a temporary graph to find a path and will not be using it ever again.
I wanted to confirm best practice if I wish to achieve this.

Hi

Yes, I’m afraid so. This package is not really optimized for those kinds of ephemeral graphs. Since you already have a predefined set of nodes and connections, it might be much simpler and more efficient to just implement a custom A* or Dijkstra on your existing graph structure.

1 Like

Thank you.

That’s what I am currently on course to implement.

The details are as follows:

Data.

  1. Custom Graph (This is my graph implementation. I use to connect elevators, vents etc)
  2. AStar Graphs
  3. Custom Node. (This is a container that can act as a node for the custom graph or hold reference to node in AStarGraph)

Operation:

  1. Each of the islands/graphs are treated as nodes and a AStar path-finding is performed on them.
  2. Since AStar Graphs are can be use and fragmented(level graph), the custom node has entry and exit positions. This helps in such an architecture since depending on neighboring nodes, the entry and exit points can differ.