Node Pathfinding Between Scenes Part I

I’m working on a little tech demo that has some similar features to Fallout 3.  It’s intended for mobile but I’m hoping to release it for desktops as well.

screen-shot-2016-11-01-at-1-03-36-pmOne neat little feature I have is the ability to load and unload scenes so that I can cut up the world into manageable chucks. This should help performance on mobile platforms tremendously.  Anyone that has played any of the more recent Fallout games will be familiar with how the system works. You walk up to a door, press the action button and the scene changes to your new location.

I was able to code something up so that I have interactive doors that when you select, unload the current level and load the new level. A door definition has a name, destination level name and destination door name. Spaces in the world are connected by doors.  That works great and I love it.

Now comes the hard part. I want to be able to set a destination point in one level and have indicators point to the closest door that the user could enter to move closer to the desired target. Sometimes, a destination could be in another level that the user would have to traverse through other levels to get to. Fallout puts indicators on doors to let you know where you should be going next on your current quest. This helps keep the player from getting totally lost in a big world.

screen-shot-2016-11-01-at-1-03-46-pm

In order to do this, we need a node graph of all our doors so that we can do node based path finding.  Since there is no master list of doors, I thought I would write a script to load each level, write out all the door values to a master list which I could then build into nodes.

Drop this script into an Editor folder and it will create a menu item under tools.

screen-shot-2016-11-01-at-1-58-38-pm

When we run it, we get the following output:

screen-shot-2016-11-02-at-8-23-55-am

Now that we have a list of doors, we can should be able to create a list of nodes where each node points to 2 doors.  From there, we can do path finding.

We’ll cover that in Part II.

Leave a Reply

Your email address will not be published. Required fields are marked *