Foundation

Foundation

Foundation is a grid-less, sprawling medieval city building simulation with a heavy focus on organic development and monument creation.

Learn more and find the game on Steam, GOG.com, Facebook, Twitter, Youtube.

Adding paths to your building

Having trouble adding paths to your building? Come here and read through this guide and use it as a checklist to get you on your way!

Posted by on


Notes:

  • This guide has only been tested for buildings and not monuments
  • Tested with latest 1.5 version
  • I use Blender 2.8 for modelling, and will be using that for this tutorial


First things first, you will need to have a functioning mod that adds a building. I will not be providing instructions on how to do that here, but may create a guide in the future. For now, your best bet would be to look at other mod's code and learning from it.

What is a path? A path shows the A.I. which direction to enter a building from (useful for doors) and also how they should move about inside the building.

Aside from modifying our model in Blender, we will also need to write a little bit of code to go alongside it, adding what's called an Asset Processor to our model.

buildings.lua

mod:registerAssetProcessor("models/test.fbx", { DataType = "BUILDING_ASSET_PROCESSOR" })


Surprisingly, that's all we need to add to our code, but of course you still need the base code for a building!

Now we can move on to Blender, and organising + adding the correct objects.

Organisation of your objects is extremely important with modding for Foundation, and requires that certain empty objects have exact names. It is likely that this guide isn't 100% accurate - and by that I mean you could probably use the name "BuildingPart" instead of "buildingPart" for your empty object - but to be safe, I would highly advise that you follow along exactly as I do. We will create an empty plain axes object, and call it buildingPart. It is important that this object is also set to position (0, 0, 0).

plain axes

We will also create an empty arrows object, and rename it to PATH_A_01.

arrows

Set the empty plain axes, "buildingPart", to be the parent of PATH_A_01 like so:

hierarchy

Our buildingPart object will be the parent of all objects (excluding construction steps), which includes the base model alongside any 'locators' (the points in space that dictate where your villagers enter a building from). We want to now move all our other objects inside this parent buildingPart, so it looks like:

hierarchy

Now that our hierarchy is all setup, we want to move PATH_A_01 around in our 3-dimensional space. The path locator must be placed on your main building's model for it to show the green arrows in-game when you place it down, and the rotation is also important but we can get to that in a sec. First, let's move PATH_A_01 to the edge of our model.

model

If we export our model now, and load it into the game, it will work. However, we have only created one of the 2 locators required for the A.I. villagers to properly work and the rotation is off. First we shall fix the rotation. When you loaded up your game, the arrow was likely facing the wrong direction. Using reference to the game, go back to Blender and alter the rotation of PATH_A_01 to suit your needs (you may need to rotate it a little to the left or right, it depends on your model, there is no right answer). Once you are satisfied that the rotation is complete, go back into the game once more to test that it is indeed working.

Next we need to create another locator, this one will be used for the position that the villager will stay in while they are performing their job (yes, that's right, they don't have to stay in the centre of the building). Create another empty arrows object like we did before, and name it PATH_A_02. Make it a child of buildingPart like we did before as well. The naming scheme of the paths increases linearly, so that if you wanted to create another locator, it would be called PATH_A_03. Why would you want more than one path, I hear you asking? That's because some building models may be very complicated and not just a straight forward walk through the door to the work station. Some models may have open courtyards and intricate interior designs that you don't want the villager just walking through. So every empty arrows object that we create is another "step" in the path that they will take. The last locator will be their resting spot.

Now that we have added a second locator, our final hierarchy should look like this:

pic7

Now loading the game, our building should be complete! Well... if you haven't finished the model maybe you want to do that!

If you want to just download all the code and models instead of doing it yourself, you can always go to my repo here.

Comments

Join the community or sign in with your gaming account to join the conversation: