Getting the Seeker from OnPathPostSearch

Hello,
I started a 2D procedural levelgenerator project and I am generating rooms. These rooms are connected in a separate step, but to make sure the exit of each room is reachable, I want to each room to have its own AIPath script. Each room generates a GridGraph at runtime and a prefab for the entrance is placed (with AIPath, Seeker and AIDestinationSetter), while the exit becomes the target of the entrance.
The pathfinding works already, however now I am stuck.
When a path fails (path.error==true), I want to generate the specific room the path belongs to again and then check the path.
So far I subscribed to AstarPath.OnPathPostSearch and this step works, however I do not have a way to identify which Seeker the path belongs to or which GridGraph the path belongs to. Can you guys please help me?


Those are the rooms I am generating, I can generate all rooms or a specific one again if the pathfinding fails. Each Entrance/Exit is the sibling of its corresponding room, so by getting the Seeker I could jump to the corresponding Room and generate it again.

GridGraphs
The GridGraphs are generated at runtime, placed at the position of the corresponding room and named after the room. I could search for the room, that has the same name to get the room. That is if I get the GridGraph that belongs to the path.

Those are the ideas I have so far, but I’m stuck nonetheless.
Thank you in advance, if you need more information I will gladly provide it.

Hi

I would recommend that you use a single large graph instead of multiple small ones.

Furthermore, you can use https://arongranberg.com/astar/docs/pathutilities.html#IsPathPossible if you just want to check if a point can be reached from another point.

So if I use a large graph, I could use “checkpoints” for each room and check if each segment can be traversed? Sounds good!
It is working now (with small graphs atm - I will change it to a big graph) but I got a follow up question: when a room is invalid and i create it again I do call AstarPath.active.Scan() after the room is exchanged, however the scan does not follow through - the scan shows the old room. Any ideas?

One GridGraph + IsPathPossible worked like a charm! Thanks

1 Like