Building System #
- To be able to place foundations, you will need to set the landscape or mesh that you want to place the foundation on, to BLOCK the buildable trace.

- To make sure that collisions are ignored in the landscape you can add the tag as in the image. Please note that this is not be required.

Principles of the system #
The building system is very extensive and has many functionalities. We will go through the most important aspects.
- Building System Component
- Trace Build location function
- Buildable
- Modular
- Snap
- Traces
- Tags
- Placeable
- Modular
- Radial Menu
- Category based generation of radial menu’s
- Damage and repair
- Parent and child buildings
- Upgrade Buildings
- Rotation and Elevation
- Add extensions when in air
- Spline Building
- Align Buildable to Normal
- Direct Placement mode
- Destruction
- Lock System
Building System Component #
The most important functionality is in the AC_BuildingSystem. This is the actor component which is also added to the character. This component handles spawning of the buildables, trace location and basically all functionality that should not be in the buildables itself.

Trace Build location function #
The key functionality is in the trace build location function. We keep ticking and check if the buildmode is on or off. When it is on, we trace the build location. When the buildmode is started, we are setting the Buildable Data which we use in throughout the complete building system component.

Opening the trace build location function shows the flow to start the building logic:
- Trace from camera
- Set location (depending on some things lice align to normal, added rotation etc.)
- Check if it is a spline or normal building
- Normal building will start the on hit logic (it the trace hits something, e.g. landscape).
- The ‘on hit’ logic checks for the basics like snapping points, overlap, floating detection etc. This determines the final location and ghost mesh color

Buildables #
We have two types of buildables, modular and placeables.

Modular:
The modular buildings are the grid-based buildings. They snap to each other, and you can make nice structures with it. In the picture below the modular pieces are shown. Be aware that these pictures are mostly without any materials, so it will look different in game. (farming plot not included)

Snap:
The snap logic is important for the modular buildings. We are doing two things to optimize snapping: Specific trace channels and Tags.

We use box collisions with a specific trace enabled so we can hit it from the trace build location function. For instance, when we want to place a wall, we only search for trace channels which blocks the Trace_Wall. In this case it is the box collisions in the modular blueprint.

Besides using the traces, we also use “tags”. When we are trying to place for instance the wall, we are searching for the Snap tag name “Wall” (as defined in the modular wall blueprint for what to search for). So, when we hit another buildable, e.g. a foundation. We will search automatically if there are snap points present for wall placement (if it has the tag “Wall)”. If it does, we will return the nearest snap point for the wall.

Placeables
When we are not building modularly, I’ve called it “placeables”. Think of furniture, campfires etc.

Datamodel #
The building system is completely datatable driven. I’ve created an excel which you can use to change data easily. Please take a good look at all the different variables which determines a big part of the functionality.

Radial Menu #
The radial menu can be opened when you have the hammer or building plan equipped. When having the building plan open you can navigate through different tabs of the radial menu.
The radial menus are created per category. I’ve created the UI_Radial_Menu_Generated_Category which you can use to drag and drop under the widget switcher in the UI_Radial_Menu. In the defaults of that widget, you can select which categories should be placed in that radial menu and which categories to ignore.

If you want to make new categories in the UI_Categories please make sure to add the functionality to the “Set Active Radial Category” function. This makes sure that it opens the correct widget.

Damage and repair #
Each buildable has durability assigned in the data table. When damage is applied is shows the health bar. You can repair it with your hammer.

Parent and child buildings #
It is more than logic that when a building on top of another building is placed, that it also gets destroyed when the foundation under it is destroyed. You also are not able to build the top first, and then the buildables under it.
When buildables are placed on top of each other they become connected. This means that when the foundation under a certain buildable is destroyed, that buildable will also get destroyed. Furthermore, you are not able to finish building a certain buildable if the foundation hasn’t been built.
To manipulate this logic check the data table for: “avoid adding as child to other buildings”

Hammer functionality #
The hammer is used for specific interactions with the buildable. The options are:
- Destruct
- Upgrade
- Cancel Upgrade
- Rotate
To execute and interaction with the hammer, look at the building you want to interact with, and select your action. It will show in the text what building you are interacting with and what will happen.

You can also upgrade buildings with your hammer. The building will not upgrade directly, but you will need to bring your resources to the upgrading buildable.

Rotation and Elevation #
By scrolling the middle mouse button or using left and right arrows when a building is not yet placed down, you rotate your buildings.
You can elevate foundations by using the up and down arrows.
When placing a foundation in the air, it will automatically add extensions under it.

Align Buildable to Normal #
In the data table, you can enable “align buildable to normal”. When doing so it will adjust to the landscape’s rotation. You can also set a minimum and maximum accepted building angle. This prevents buildings to be able to placed on too steep angles.

Direct Placement mode vs Ghost build mode #
Default I use the ghost build mode. This means that don’t have to bring resources to the building before being placed. A ghost building will spawn, and after that you can add resources to finish the building.
However, I also can image the need of direct placement. In the data table you can enable “Direct placement mode” to set the building directly to finished on placement. It will subtract the required resources from your inventory directly. I have set the forge to direct placement mode so you can test it out.

Destruction #
You would want to enable destruction when the health is zero of a buildable. The health is tracked in the “deal and process damage to buildable” function in the Buildable blueprint. Based on the tier and buildable type we’re creating a chaos spawn blueprint. This blueprint has a geometrycollection which will show chaos-based destruction.

Lock System #
You can place locks on doors. When a lock is placed, you will need to enter the password so you can open the door. The default password is 0000. You can change the password by doing a password reset. If done so, only people with the correct password will be able to authorize to open the door.

Basic Spline Building #
I’ve added spline building functionality so we can create defense walls. I’ve added a gate frame in which you can place doors. The spline does not snap and is intended for basic defense walls.
When placing the spline, I wanted to be able to build only segments of that spline. So, it calculates segment placement nicely. This is done by placing buildable masters along the spline and couple the spline segments to these buildable masters.

Cabinet #
To be able to claim certain territories we’ve created a cabinet. This cabinet works with authorization. When a player is authorized, you can place in the set radius. If you’re not authorized, you are unable to place anything as seen in the picture below.

use cases #
Add new placeable to radial menu #
To add your own buildable to this system you must do a couple of things. First is all it is important to add a new entry in the buildables data table. In this entry you can change the settings to whatever you like. When you’ve changed all the settings you want, you should set the correct category so the buildable is correctly set in the radial menu. When that is finished you can build your buildable in the world.
