Pathfinding on randomly generated terrain?

Howdy;

I have a randomly generated dungeon (multi level, though pathfinders dont need to travel between levels)

As the map is randomly generated, and there are things above and below it (thus no heightmap or anything) what’s the best way to do pathfinding?

(If it helps, the random generation is based on a series of differently based prefab tiles, but isn’t grid based)

…uh, bump :slight_smile:

Is your terrain generated during play mode? Cause there really isnt alot out there for that. I am working on a dynamic navigation system where obstacles can be place or moved and the navigation will be updated… But, generating the actual entire grid/navmesh at run time is a different story…

I’d recommend the use of ‘nodes’ built in to your prefabs. These nodes might indicate, for example -

A list of all nodes that can currently be reached directly from this node (for example, closing a door might remove a node from this list), and perhaps a “distance to that node” for each of those nodes - calculable at runtime, but for efficiency might be good to calculate in the editor.
A radius - a pathing actor is “at” this node once they’re within this distance
Node type - transition between prefabs, door, cover, etcetera.

It’s not too difficult to brute-force seek a path from any one node to another with this setup, and it’s reasonably quick to operate as well, especially if you cache common paths and/or use coroutines to build paths (rather than ask for a path and patiently wait until it’s completely discovered).

1 Like