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:
- 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.
- 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:
- 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 unit’s object be destroyed after it hits zero health (if the above option is enabled).
- 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 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:
- 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.
- Rotate While Idle: Can the unit rotate when it’s idle to face its destination position?
- Rotation Damping: In case the above toggle field is enabled, how fast does the rotation updates?
Unit Damage Settings:
- Take Damage: When disabled, then the unit won’t take damage and will be invincible.
- 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 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.
- 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 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
- Obj Type: Set to Unit.
- Can Select: Can this unit be selected?
- Select Owner Only: When enabled, only the owner of this unit will be able to select it.
- Minimap Icon Size: Represents the size of the minimap icon for this unit.
- 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).
- 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 map, this layer is called: “GroundUnitTargetPos”.
- 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.
- Movement Sound Effect: Audio clip played (on loop) when the unit is moving.
- Invalid Path Sound Effect: Audio clip played when the movement path is invalid.