Building System #
The building system is very extensive and has many functionalities.
Building System Component #
The most important functionality is in the AC_BuildingSystem, which is added to the character. This component handles spawning of the buildables, trace location, and all functionality that should not be in the buildables themselves.
Trace Build Location Function #
The key functionality is in the trace build location function. When build mode is on, the build location is traced. When build mode is started, the Buildable Data is set, which is used throughout the building system component.
Opening the trace build location function shows the flow to start the building logic:
- Trace from camera
- Set location (depending on align to normal, added rotation, etc.)
- Check if it is a spline or normal building
- Normal building will start the on hit logic (if the trace hits something like a landscape)
- The on hit logic checks for basics like snapping points, overlap, floating detection, etc. This determines the final location and ghost mesh color.
Buildables #
There are two types of buildables: modular and placeables.
Modular #
Modular buildings are grid-based and snap to each other to create structures. These pictures are mostly without materials, so they will look different in the game.
Snap #
Snap logic is important for modular buildings. It uses specific trace channels and tags. Box collisions with a specific trace enabled are used, and tags help find snap points for walls, foundations, etc.
Placeables #
Placeables are non-modular items like furniture and campfires.
Datamodel #
The building system is data table driven. An Excel file is provided for easy data changes. Review all the variables that determine functionality.
Radial Menu #
The radial menu can be opened when the hammer or building plan is equipped. Navigate through different tabs of the radial menu. The menus are created per category, and you can create new categories in the UI_Categories.
Damage and Repair #
Each buildable has durability assigned in the data table. When damage is applied, it shows the health bar. Repair it with your hammer.
Parent and Child Buildings #
When a building is placed on top of another, they become connected. Destroying the foundation destroys the buildable on top. You can’t build the top first and then the buildables under it. Adjust this logic in the data table.
Hammer Functionality #
The hammer is used for interactions with the buildable, such as destruct, upgrade, cancel upgrade, and rotate. Look at the building and select the action. You can also upgrade buildings with your hammer.
Rotation and Elevation #
Rotate buildings with the middle mouse button or left and right arrows. Elevate foundations with up and down arrows. Placing a foundation in the air automatically adds extensions under it.
Align Buildable to Normal #
Enable “align buildable to normal” in the data table to adjust to the landscape’s rotation. Set a minimum and maximum accepted building angle to prevent placement on steep angles.
Direct Placement Mode vs. Ghost Build Mode #
The default mode is ghost build, where resources are added to the building after placement. Direct placement mode sets the building to finished on placement and subtracts resources from your inventory directly. Test this with the forge set to direct placement mode.
Destruction #
Enable destruction when the buildable’s health is zero. Health is tracked in the “deal and process damage to buildable” function. Based on the tier and type, a chaos spawn blueprint is created for destruction.
Lock System #
Locks can be placed on doors, requiring a password to open. The default password is 0000, which can be changed. Only authorized users can open the door.
Basic Spline Building #
Spline building functionality is added for creating defense walls. A gate frame can place doors. The spline does not snap and is intended for basic defense walls. The spline calculates segment placement and couples segments to buildable masters.
Cabinet #
A cabinet is used to claim territories and works with authorization. Only authorized players can place items in the set radius.