Add Building to Map
Go ahead and load a map scene. For this tutorial, we will be loading the tutorial_map created in the Set New Map tutorial.
1. Add Building to Faction Slot
In the Setup Faction Slots tutorial, we went through setting faction slots up for a map scene where we've dealt with setting pre-placed (or initial) faction entities for each slot. In short, the initial faction entities are units and buildings that a faction starts with. These need to be to set in the Game Manager component.
Select the Game Manager object and expand the player's faction slot (it is the one where the Is Local Player field is enabled. In the tutorial_map, it should be the first slot):
This faction slot has two initial faction entities: new_building and new_unit. We want to remove the new_building faction entity from this list and delete its object from the scene first. Since the new_building is also assigned to the Initial Cam Look At Position of this slot, replace it with the new_unit object which we will be keeping so that the player's camera will initially look at the unit object when the scene starts.
Now it is time to add the new building prefab. For this tutorial, we will be adding the tutorial_building created in the last part of this tutorial. Find the tutorial_building in the project tab and drag it into the current map scene. To keep things organized, we will keep it as a child object of the Factions object in the scene, where all other initial faction entities are placed. Place the building at position (45,0.1,45) and your scene should look something like this:
The next step is to add the building to the faction slot's Initial Faction Entities in the Game Manager component so that it would be properly initialized as part of that slot.
Now start the scene and you should be able to see the building we added initialized with its construction object shown instead of the model. If you select the building, you would see that it has 1/100 health points. It was initialized with 1 health points and therefore went into construction mode. The building needs to be constructed by a Builder unit, which we will get to alongside building placement in another section.
Stop the game and select the building's parent object, expand its Building Health component and assign its initial health to 100 (the maximum allowed value).
Run the scene again and the building would now be initialized fully constructed!
2. Add Building to Free Faction
Buildings can also be added to a map scene without having to belong to any faction slot, in this case, they are referred to as free buildings. To add a free building, drag and drop the building's prefab into the map scene. We will be using the same tutorial_building in this example, so drag it into the scene and set its position to (50, 0.1, 50) and set its initial health to 100.
In order to initialize the free building properly, it needs to be added to the Free Buildings array field of the Building Manager component which can be found under Game Manager -> Essential -> BuildingExtension. In the same component, the Free Building Color field allows to set a special color for all free buildings in the map scene.
Here is how the scene should like when you start it:
Download Files
You can download the results of this tutorial here.