Unity RTS Engine

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

Unit Main Component

The unit’s parent object has 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.

Unit General Settings:

  1. Unit Name: The name that will be displayed when the unit is selected.
  2. Unit Code: Assign a unique code for each unit.
  3. Unit Category: The category that this units belongs to.
  4. Unit Description: A description for the unit that will be displayed when the unit is selected.
  5. Unit Icon: An icon for the unit that will be displayed when the unit is selected.
  6. Free Unit: 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.
  7. Faction ID: If this unit comes ready with the map. Then you must assign the faction ID manually. If not, leave this empty.
  8. Unit Height: Nav Mesh Agent base offset will be overwritten with the value in this field.
  9. Air Unit: If this unit is supposed to fly, then enable this field & set the flight height in the “Unit Height” field.

Unit Health Settings:

  1. Maximum Unit Health: Maximum health points for this unit.
  2. Hover Health Bar Height: When moving the mouse over a unit’s object, a health bar would appear. This is the health bar’s position on the y axis.
  3. Destroy Object: When disabled, the unit’s object won’t be destroyed when the unit dies.
  4. Destroy Object Time: After how much time (in seconds) should the unit’s object be destroyed after it hits zero health (if the above option is enabled).
  5. Destroy Award: This array allows the faction that killed this unit to get resources as a reward. The resource types and their respective amounts can be assigned inside this array.
  6. Unit Destruction Effect/Audio: When the unit is dead, you can play an audio clip that you assign to the “Destruction Audio Clip” field and/or spawn a special effect that you assign to the “Destruction Effect Obj” at the unit’s death position.

Unit Movement Settings:

  1. Can the unit be moved: When disabled, then the player won’t be able to command the unit to move around the map.
  2. Movement Speed: The unit’s movement speed.
  3. Rotate While Idle: Can the unit rotate when it’s idle to face its destination position?
  4. Rotation Damping: In case the above toggle field is enabled, how fast does the rotation updates?

Unit Damage Settings:

  1. Take Damage: When disabled, then the unit won’t take damage and will be invincible.
  2. Stop Movement On Take Damage: When enabled, the unit’s movement will be stopped when it takes damage.
  3. Play Take Damage Animation: When enabled, the Take Damage state in the animator will be enabled and the correspondent animation will be played.
  4. Take Damage Duration: This is basically the duration of the Take Damage animation.


  1. Can Wander: Enable this option to allow the unit wander.
  2. Wander By Default: When enabled, then as soon as the unit spawns it will start wandering.
  3. Fixed Wander Center: When enabled then the unit will have a fixed wander center (which is the unit’s position when it first started wandering). When the above option is enabled as well, then the unit will simply keep wandering around its spawn position.
  4. Wander Range: How far can the unit wander to?
  5. Wander Reload Range: Duration between each time the unit decides to go to a different position.

There are also two tasks that appear for units who have wandering enabled, one to enable it and one to disable. For more information about these tasks please check the Unit Manager documentation page.

Escape On Attack:

  1. Escape On Attack: Enable this option if you’d like the unit to escape when it gets attacked. As an example, this can useful for animals which the player hunts, once attacked they start escaping.
  2. Escape Range: How far will the unit escape?
  3. Escape Speed: When escaping, units can have a different movement speed (the value in this field).
  4. Escape Animator Controller: It is also possible to change the unit’s movement animation when escaping by using an Animator Override Controller.

Unit Components:

  1. Unit 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.
  2. Unit Animator: Drag and drop the unit’s animator in this field (if the animator is placed on the main unit’s object then you can ignore this, it will be set automatically).
  3. Unit Plane: This is the object that holds the selection texture and which will be activated when the unit is selected. This object includes a mesh renderer as it will be colored in the faction’s color when activated. Also a child object of the main unit’s object and has “Unit” as its layer.
  4. Unit Selection Component: The selection collider must not 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 unitand also acts as hitbox for attack objects. It also has the Selection Obj component attached to it. The selection object is then assigned to the “Unit Selection Component” field in the Unit component, the Selection Obj component has the following fields
    1. Obj Type: Set to Unit.
    2. Can Select: Can this unit be selected?
    3. Select Owner Only: When enabled, only the owner of this unit will be able to select it.
    4. Minimap Icon Size: Represents the size of the minimap icon for this unit.
  5. Default Animator Override Controller: Drag and drop here the main animator override controller for this unit (this field is optional if you are using an independent Animator Controller for the unit).
  6. Unit Damage Effect: An object that will be spawned each time the unit receives a damage. This object must have the EffectObj component. For more information about effect objects and how to create them, check out this documentation page.
  7. Target Position Collider: Each unit must have an empty child object with only a collider as a component. The collider must have “Is Trigger” enabled as well. This collider represents the space that the unit occupies in the map so that it doesn’t coincide with another unit. This object must also have a layer that belongs to the “Unit Layer Mask” of the Movement Manager. For example, in the demo map, this layer is called: “GroundUnitTargetPos”.
  8. Faction Color Objects: Drop and drag objects that have a Mesh Renderer/Skinned Mesh Renderer component that are children of the main unit object and that you want to color their mesh with the color of the faction.

Audio Clips:

  1. Selection Sound Effect: Audio clip played when the player selects this unit.
  2. Movement Order Sound Effect: Audio clip played when the unit is ordered to move.
  3. Movement Sound Effect: Audio clip played (on loop) when the unit is moving.
  4. Invalid Path Sound Effect: Audio clip played when the movement path is invalid.

How can we help?