Unity RTS Engine

  1. Home
  2. Unity RTS Engine
  3. Buildings
  4. Building Component

Building Component

The building’s parent object must have the Building component attached to it. This is the main component that defines a building. The building’s parent object must have its layer set to “Building” as well.

  1. Name: The name that will be displayed when the building is selected.
  2. Code: Assign a unique code for each building which the system will use to identify the building.
  3. Category: The category that this building belongs to.
  4. Description: A description for the building that will be displayed when the building is selected.
  5. Icon: An icon for the building that will be displayed when the building is selected.
  6. Free: If true, then this building will not belong to any faction.
  7. Task Panel Category: When using categories in the task panel (UI Manager), this is the ID of the task panel that this building belongs to when it appears while selecting builder(s). Task Panel categories allow to organize tasks based on a criteria that you can decide.
  8. Radius: This is the radius of the building that units use to interact with the building (when the building is selected in scene view, a blue gizmo sphere will appear in the scene view displaying the radius). Make sure that the radius is bigger than the Navigation Mesh Obstacle component size so that units can successfully interact with the building.
  9. Faction ID: If this building comes ready with the map (for example, the capital building must always be present in the scene when creating it). Then you must assign the faction ID manually. If not, leave this empty.
  10. Add Population Slots: A building can increase the maximum population amount for a faction by setting this field to the amount that it adds.
  11. Faction Colored Renderers: Drag and drop objects that have a “Mesh Renderer” or a “Skinned Mesh Renderer” component that are children of the main building object which you want to color with the faction’s color in the Renderer field. For each one, specify the ID of the material that you want to color in the Material ID field.
  12. Selection Plane: This is the object that holds the selection texture and which will be activated when the building is selected. This is a child object of the main building object that includes a Mesh Renderer component as it will be colored in the faction’s color when activated.
  13. Model: Drag and drop the building’s model object in this field (it must be a child object of the main building prefab). The building’s model object must have the “Building” layer. Make sure that when the building’s parent object is placed at the same Y-Axis as the terrain, the building’s model is completely over the terrain and is totally visible.
  14. Building Selection: The selection collider can’t be the same as the building’s frontier collider. It’s a child object of the building parent object. It includes a Collider component with “Is Trigger” set to true. This collider represents where the player has to click with the mouse in order to select the building and also acts as hit-box for attack objects. It also has the Building Selection component attached to it. The selection object is then assigned to the Building Selection field in the Building component, the Building Selection component has the following fields
    1. Can Select: Can this building be selected?
    2. Select Owner Only: When enabled, only the owner of this building will be able to select it.
    3. Minimap Icon Size: Represents the size of the minimap icon for this building.
  15. Bonus Resources: A building can affect how fast units could collect resources in its area (its area is determined by the size of the border that belongs to the nearest building center). For example, to increase the speed of collecting Food resources, you would just and drag and drop the food Resource Type Info asset in the Resource Type field. And then input the one unit collection reduction time in the Duration Reduction field.
  16. Spawn Position: For buildings that can produce units. A position for spawning units must be chosen. Therefore, create a new child object of the building, assign the “Building” layer to it, place it wherever you want the units to appear at when they are created. And drag and drop that object into this field.
  17. Goto Position: When the units spawn at their spawn position, you can assign a goto position to them meaning that as soon as they spawn, they will move to the goto position. Create a new child object of the building, assign the “Building” layer to it, place it wherever you want the units to go to after they spawn. And drag and drop that object into this field. You can also assign a model for this object which will appear in game when the building is selected. Right clicking on any free part of the terrain when selecting a building that has a goto transform assigned, will set the goto position to where the player has clicked allowing the player to change the goto position in game.
  18. Selection Sound Effect: Audio clip played when the player selects this building.

How can we help?