Add the Unit component to the main unit object and configure it from the inspector.
Unit General Settings:
- Unit Name: The name that will be displayed when the unit is selected.
- Unit Code: Assign a unique code for each unit.
- Unit Category: The category that this units belongs to.
- Unit Description: A description for the unit that will be displayed when the unit is selected.
- Unit Icon: An icon for the unit that will be displayed when the unit is selected.
- 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.
- Faction ID: If this unit comes ready with the map. Then you must assign the faction ID manually. If not, leave this empty.
- Unit Height: Nav Mesh Agent base offset will be overwritten with the value in this field.
- Flying Unit: Is this unit supposed to fly? (like an airplane, helicopter, etc ..). If yes then enable this option.
Unit Health Settings:
- Maximum Unit Health: Maximum health points for this unit.
- 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.
- Destroy Object: When disabled, the unit’s object won’t be destroyed when the unit dies.
- Destroy Object Time: After how much time (in seconds) should the game object of the unit be destroyed after its death.
- 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.
Unit Movement Settings:
- Can the unit be moved: When disabled, then the player won’t be able to command the unit to move around the map.
- Movement Speed: The unit’s movement speed.
- Rotation Damping: How fast does the rotation updates?
Unit Damage Settings:
- Stop Movement On Take Damage: When enabled, the unit’s movement will be stopped when it takes damage.
- Play Take Damage Animation: When enabled, the Take Damage state in the animator will be enabled and the correspondent animation will be played.
- Take Damage Duration: This is basically the duration of the Take Damage animation.
- Can Wander: Enable this option to allow the unit wander.
- Wander By Default: When enabled, then as soon as the unit spawns it will start wandering.
- 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.
- Wander Range: How far can the unit wander to?
- 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:
- 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.
- Escape Range: How far will the unit escape?
- Escape Speed: When escaping, units can have a different movement speed (the value in this field).
- Escape Animator Controller: It is also possible to change the unit’s movement animation when escaping by using an Animator Override Controller.
- 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).
- 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.
- Unit Selection Component: The selection collider must not be the same as the unit’s main collider. Therefore, create a new empty object and make it child of the main unit’s object. Then add a Collider to this object (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 hitbox for attack objects. Finally, add the SelectionObj component to the selection object and drag and drop this object to the “Unit Selection Component” field in the Unit component, the SelectionObj component has the following fields
- Obj Type: Set to Unit.
- Minimap Icon Size: Represents the size of the minimap icon for this unit.
- Main Animator Override Controller: Drag and drop here the main animator override controller for this unit. If the unit doesn’t use another animator override controller for the Builder component for the Escape On Attack behavior then you can leave this field empty.
- 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.
- 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 scene, this layer is called: “UnitTargetPos”.
- 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.
- Selection Sound Effect: Audio clip played when the player selects this unit.
- Movement Order Sound Effect: Audio clip played when the unit is ordered to move.
- Invalid Path Sound Effect: Audio clip played when the movement path is invalid.