Room Path Generator

So I have been trying to write a script in JavaScript, but have been pretty stumped on this for the past few hours. So pretty much, here is the scene: There are multiple rooms with varying amounts of doors that lead to other rooms. What I want, is for an AI to be able to find a path from what ever room it’s in, to another room. To be able to find every door in which it needs to get through to reach it’s destination room.

Here is an example along with a picture:

Let’s say the AI is in room number 2, and wants to go to room 7. I need an idea for a script that calculates what doors it will need to go through to make it from room 2, to room 7. For example, it would have to take the door that leads to room 1, the door that leads to room 3, then the door that leads to room 7. (Each black line represents which door leads to which. Example: The door on the right of room 1 leads to the middle door in room 3)

40377-algorythem-problem.png

I have had multiple ideas, all failing. I am asking simply for an idea, a place to start with this. I’ve tried for several hours, almost making it nowhere. Thanks in advance.

Sounds like you’re looking for Pathfinding.

See http://answers.unity3d.com/questions/9025/pathfinding-tools-in-unity.html