Buildable

Next up, we’ll make a decorative buildable - the Plantpot of Knowledge, a monument to your progress in the tutorials thus far. A buildable is simply anything you will be able to place with the buildgun. Even if it is just a simple foundation or fence, it is still an FGBuildable.

Like items, buildables have descriptors to define their names and descriptions, but they also have an actor representation to act as the structure in the game world. There’s also a hologram which controls its placement. We don’t need a conveyor mesh for our building, since our buildings probably shouldn’t be moving around as items on conveyor belts. However, we’ll definitely still want a mesh for our building’s appearance in-game.

To stay organized, we’ll create a separate folder for each of our buildables to hold their textures, meshes, and so on in one place. Create new folder called "Buildables" in your mod’s root folder, then create another folder for our first Buildable. Let’s call it "DocBuild".

Adding the Actor

Next, create a blueprint of type FGBuildable with f.e. the name "Build_DocBuild" inside your folder. This is the actual building object in which the model and factory logic are defined, among other things.

Now we need to populate the buildable description by simply filling the default values. Set M Hologram Class to FGBuildableHologram, which will cause the FGBuildable to automatically find the hologram by itself.

Fill M Display Name with something like "Doc Buildable" and M Description with "An example building that showcases the MI_Factory_Base_01 material.".

Holograms control how buildings get placed. Later on, you can write your own to allow upgrading buildings or to have snapping functionality. You can learn more about how holograms work on the Buildable Holograms page.

As you can see in the Components pane in the top left, the actor already contains a few components. But not any visuals, so, now add a new static mesh component in the center of the viewport. The build gun uses the origin when targeting the mesh to be built or snapped. You can use this example Mesh, the Plantpot of Knowledge, for your buildable.

This Actor is also where you can define the snapping area and the clearance area, but we won’t do that for now. Look to other machines and examples for inspiration as there are several relevant settings to make those behaviors work correctly.

Make it paintable

We want to make our buildable paintable, meaning, able to be painted it with the paint gun. Because the FGBuildable-class already provides a basic implementation for that, we just need our buildable’s mesh to use the MI_Factory_Base_01 material. The provided example mesh already provides a proper UV map for said material, so you will not need to edit the UVs of the provided mesh. You will need to do so for your own models. More info on the materials already in the game can be found at Main Materials documentation page.

You must ensure that the materials of the Mesh and Buildable are set to point to a material called MI_Factory_Base_01 within Content/FactoryGame/-Shared/Material. If this does not exist, create a placeholder material in its place, and it will point to the correct texture within the game.

More than one MI_Factory_Base_01 material may appear in your search. Make sure you select the one located at /Game/FactoryGame/-Shared/Material. Hover over it in the picker to check the path.

Adding the Descriptor

Similar to how we created a descriptor for our item, we now need to create one for our buildable of type FGBuildingDescriptor.

Simply add a new Blueprint of type FGBuildingDescriptor to the same folder as the buildable itself and call it f.e. "Desc_DocBuild".

The building descriptor is very similar to the item descriptor - it even derives from it. It comes with a few extra fields, such as a FGBuildable-Class reference (set this to your Build_DocBuild actor) and some Build-Category stuff that you can set up as you see fit.

Just like our item, it requires an icon file. You can use this example as the icon.

You should also add an appropriate subcategory in the m Sub Categories field for your building.

Make sure you use FGBuildingDescriptor and not FGBuildDescriptor.

Define the Recipe

To define how our building is constructed we will use an FGRecipe, just like we did for our custom item. Create a new FGRecipe asset and set ProducedIn to FGBuildGun, then add Ingredients entries to define the cost of constructing the building. The Product field should contain exactly one entry - the FGBuildingDescriptor asset you just created for your buildable.

That’s it! You don’t need to register anything else. When the recipe gets loaded, everything else also gets loaded and the buildable in the save file has soft references to the classes, and if they get loaded also the classes like our newly created buildable get loaded.

Trying it Out

If you load up the game now, you should be able to build the Doc Build in game, but it is purely an object that sits there and exists. You should be able to paint it with the paint tool, and it should look roughly like it does in the icon image.

Troubleshooting

Placing the building creates nothing in the world

Make sure that your building has an instanced static mesh component and that a mesh is assigned to it.

Building has a gray checkerboard texture

Check in both the Buildable’s mesh component the mesh’s own settings that the correct Factory Inst texture is selected.

Building doesn’t appear in the build gun

  • Make sure all of your mod files are saved before packaging the mod.

  • Make sure the FGBuildingDescriptor has a category and sub-category set. Without one, the build gun doesn’t know where to display it and it will only appear when directly searched for.

  • Check that BP_BuildGun is in the producers list of the FGRecipe.

  • Ensure the recipe is in the Unlock array of a schematic you have created.

  • Ensure the schematic unlocking the recipe is listed in your root Game World Module.

  • Check that you have purchased the schematic in-game.

Crash when selecting the building in the build gun

The crash message will likely contain UStruct::IsChildOf() and AFGBuildGun::GotoBuildState()

You forgot to assign a hologram class in the FGBuildable - the default is None, which leads to this crash.

Something Else

If something went wrong, feel free to contact us on the Discord for help.

Next Steps

In the next section, we’ll make another buildable that has some custom logic, allowing it to act as an item counter.