Unity RTS Engine

  1. Home
  2. Unity RTS Engine
  3. Units
  4. Unit Component

Unit Component

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

  1. Name: The name that will be displayed when the unit is selected.
  2. Code: Assign a unique code for each unit.
  3. Category: The category that this units belongs to.
  4. Description: A description for the unit that will be displayed when the unit is selected.
  5. Icon: An icon for the unit that will be displayed when the unit is selected.
  6. Faction ID: If this unit comes ready with the map. Then you must assign the faction ID manually. If not, leave this empty.
  7. Can Be Converted: When enabled, then a converter from an enemy faction will able to convert this faction.
  8. Free: If true, the unit will not be controlled by any faction in the game. For example, orcs are used in the demo scene to protect treasures that are located in the map, these orcs are free units, they don’t belong to any faction.
  9. Population Slots: The amount of the faction’s population slots that this unit occupies.
  10. Faction Colored Renderers: Drag and drop objects that have a “Mesh Renderer” or a “Skinned Mesh Renderer” component that are children of the main unit 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.
  11. Selection Plane: This is the object that holds the selection texture and which will be activated when the unit is selected. This is a child object of the main unit object that includes a Mesh Renderer component as it will be colored in the faction’s color when activated.
  12. Model: Drag and drop the unit’s model object in this field (it must be a child object of the main unit prefab). The unit’s model object must have the “Unit” layer. Make sure that when the unit’s parent object is placed at the same Y-Axis as the terrain, the unit’s model is completely over the terrain and is totally visible.
  13. Unit Selection: The selection collider can’t be the same as the unit’s frontier collider. It’s a child object of the unit 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 unit and also acts as hit-box for attack objects. It also has the Unit Selection component attached to it. The selection object is then assigned to the Unit Selection field in the Unit component, the Unit Selection component has the following fields
    1. Can Select: Can this unit be selected?
    2. Select Owner Only: When enabled, only the owner of this unit will be able to select it.
    3. Minimap Icon Size: Represents the size of the minimap icon for this unit.
  14. Animator: Drag and drop the object that holds the Animator’s component in this field.
  15. Animator Override Controller: Drag and drop the main animator override controller for this unit. For more information about animators and animator override controllers, check out this documentation page.

How can we help?