Connecting Rooms

Hi there.

The game we are working on is procedurally generated so I’ve created my own NavGraph and its going really well.

The levels are going to be pretty large with lots of connecting rooms and corridors. I need to come up with a way to make sure when the enemy path find to a location that resides in the same room its in, they don’t try and path find out the hallways.

I noticed the system breaks up my connecting nodes into “areas”. I can easily make each room and hallway its own area like this.

blue - room 1, yellow - corridor, red - room 2.

But I still need them to be able to pathfind from one room to another.

Any suggestions?

Use off mesh links and then ask for shortest path. The example script “AIFollow” shows this. The default behavior of the pathfinding toolkit is to find shortest path.
This means that if they want a point in the same room, they will search for a shortest path and wont go out into the hallway to do so.

This is assuming all the graphs for each room are connected and such (to allow for pathfinding to other rooms as well).

From the looks of your image, the room1, corridor, and room2 are not connected graphs. So the pathfinding will fail as there isn’t a valid path from room1 to room2 (using the graphs) to another room. Try to make the graphs contiguous and connected or use off mesh links. If you separated the graphs for location naming you could use volumes or invisible meshes that define locations inside of them and then have the graphs all connected…

Each enemy in our game has different jump heights. I’ve already modified the pathfinding code to allow this.

Enemy 1 has a jump height of 4.

Enemy 2 has a jump height of 2.

If the player is on a high platform, Enemy 1 will find a path to him, but enemy 2 will not. If all the rooms are connected into a seamless graph, enemy 2 will check every node in the level for a viable path…

If I could limit the enemies search to just the room they are in. it would mean enemy 2 only checks 1000 nodes instead of 50k+ nodes

I was thinking about having 2 graphs. one would be like the one above but seamless.
Then any nodes that connects 2 areas mark with a tag and a room ID
Then have a really simple one that has a node per room and assign a room ID.

When asking for a path, it would first find a path on the simple graph, find what rooms/corridors it went through. then if the pathfinding tried to process a connecting node, it would check if the room ID is in the simple path before flagging it as an open node.

I also have a similar problem, I stream in rooms (mesh data and navigation graph) from my server and I need to find a way to connect the navigation graphs together as the rooms stream in. Is this possible?

1337, you mention off mesh links, is there a way I could procedurally create links when I finish loading a new room?