The unit’s parent object has the following Unity components. This documentation page discusses the role of each one of this components.
Collider component with Is Trigger set to true. This collider defines the unit’s boundaries in relation to obstacles in the map.
Rigidbody component with Is Kinematic set to true and Use Gravity set to false.
The Audio Source component with:
- Spatial Band set to 3D (equal to 1).
- Under 3D Sound Settings:
- Doppler Level and Spread both set to 0.
- Volume Rolloff set to Linear Rolloff.
- Min Distance and Max Distance set to values that mirror how loud you want sound coming from the unit to be heard from distance.
Navigation Mesh Agent:
The Nav Mesh Agent component allows the unit to move on the navmesh.
Set the Radius field to the area that you want the unit to occupy on the navigation mesh and make sure that Obstacle Avoidance Quality is set to none.
Next define the Path Finding Area Mask to include the “Walkable” area in case the unit is supposed to move on the terrain. In case this is a flying unit, remove the “Walkable” area from the mask and include the area that you’ve assigned to your air terrain. For more information about the air terrain and how to create it, check out the Terrain Manager.
If you want to animate your units while they are attacking, collecting resources, building, etc.. Then you need an Animator component attached to the main unit object (or the unit model but in this case you need to assign the animator in the main Unit component which will be covered in the next documentation page). The animator controller below can be found under RTS Engine\Units\Sources\Animations\Controllers. This controller is composed of 8 states: Idle, Moving, Collecting, Building, Attacking, Take Damage, Healing, Converting and Dead and 10 Boolean parameters (one for each state): IsIdle, IsMoving, InMvtState, IsCollecting, IsBuilding, IsAttacking, TookDamage, IsHealing, IsConverting and IsDead.
It’s advised that you create an Animator Override Controller for each unit and then have the above Unit Animator in the Controller field of the animator override controller. This way you don’t have to re-create the animator controller for each unit but simply replace the empty animations with the ones you want to use for the unit you’re creating. Then you can simply attach the animator override controller in the Animator Override Controller field of the Unit component (also covered in the next documentation page).